Full Step-by-Step Process:
-
Check if the
.tarfile exists:ls
-
If the
.tarfile doesn't exist, save the Docker image as a.tarfile (replace<image_name>with the name of the Docker image, e.g.,docker-django-deploy):docker save -o <tar_file> <image_name>
-
Load the Docker image from the
.tarfile (replace<tar_file>with the actual file name, e.g.,docker-django-deploy.tar):docker load -i <tar_file>
-
Check the running containers (to identify the container name):
docker ps -a
-
Inspect the container to find the PID (replace
<container_name>with the actual container name, e.g.,happy_bartik):docker inspect --format '{{.State.Pid}}' <container_name>
-
Kill the process using the PID (replace
<PID>with the actual PID obtained from the previous command):sudo kill -9 <PID>
-
Stop the container (replace
<container_name>with the actual container name, e.g.,happy_bartik):docker stop <container_name>
-
Rerun the project using the loaded image (replace
<image_name>with the actual image name, e.g.,docker-django-deploy):docker run -p 8000:8000 <image_name>
Example:
-
Check if
.tarfile exists:ls
-
Save the image to a
.tarfile:docker save -o docker-django-deploy.tar docker-django-deploy
-
Load the Docker image from the
.tarfile:docker load -i docker-django-deploy.tar
-
Check running containers:
docker ps -a
-
Inspect the container to find its PID:
docker inspect --format '{{.State.Pid}}' happy_bartik -
Kill the process with the PID:
sudo kill -9 70630 -
Stop the container:
docker stop happy_bartik
-
Rerun the project:
docker run -p 8000:8000 docker-django-deploy
