Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Load Image Locally

Latest

Choose a tag to compare

image

Full Step-by-Step Process:

  1. Check if the .tar file exists:

    ls
  2. If the .tar file doesn't exist, save the Docker image as a .tar file (replace <image_name> with the name of the Docker image, e.g., docker-django-deploy):

    docker save -o <tar_file> <image_name>
  3. Load the Docker image from the .tar file (replace <tar_file> with the actual file name, e.g., docker-django-deploy.tar):

    docker load -i <tar_file>
  4. Check the running containers (to identify the container name):

    docker ps -a
  5. 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>
  6. Kill the process using the PID (replace <PID> with the actual PID obtained from the previous command):

    sudo kill -9 <PID>
  7. Stop the container (replace <container_name> with the actual container name, e.g., happy_bartik):

    docker stop <container_name>
  8. 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:

  1. Check if .tar file exists:

    ls
  2. Save the image to a .tar file:

    docker save -o docker-django-deploy.tar docker-django-deploy
  3. Load the Docker image from the .tar file:

    docker load -i docker-django-deploy.tar
  4. Check running containers:

    docker ps -a
  5. Inspect the container to find its PID:

    docker inspect --format '{{.State.Pid}}' happy_bartik
  6. Kill the process with the PID:

    sudo kill -9 70630
  7. Stop the container:

    docker stop happy_bartik
  8. Rerun the project:

    docker run -p 8000:8000 docker-django-deploy