"Will code for travel"

Search technical info
Frequently Used Commands for Docker
Written: 2021-10-19 18:46:22 Last update: 2023-05-22 15:05:57
  1. How to load a docker image file
    $ docker load -i <filename.tar>
  2. How to save loaded Docker image to a docker image file (no compression)
    $ docker save -o my_docker_file.tar loaded_image_name:version
    With compression
    $ docker save loaded_image_name:version | gzip > filename.tar.gz
  3. How to start a container from a loaded image and see its log
    $ docker up
    How to start a container from a loaded image in detached mode
    $ docker up -d
  4. How to list all containers in short format
    $ docker ps --format "{{.ID}}\t{{.Names}}"
  5. How to see a container's IP address
    $ docker inspect <container_id> | grep IPAddress
  6. How to stop container only.
    $ docker down
    How to stop a container and remove its volume (remove saved data)
    $ docker down -v
    How to remove a stopped container
    $ docker rm <container_id>
    How to remove all stopped containers
    $ docker container prune
    How to remove all stopped containers and remove their data
    $ docker system prune
  7. How to go inside a container (non distroless)
    $ docker exec -it <container_name> bash
  8. How to log in to a postgres container?
    $ docker exec -it <container_id> psql -d <table_name> -U <username>
  9. How to reset password?
    $ docker exec -it <container_name> python3 manage.py changepassword <email_id>
Tags: docker
Search more info