Docker Quick Reference

View/Change Container Status
    docker ps                 {list running containers}
    docker ps -a              {list all containers even exited ones}
    docker container pause ID {pause running container}
    docker container stop ID  {stop running container}
    docker container kill ID  {Kill a running container}
    docker logs -f ID         {continually follow output of container}
 
Access Running Container
   docker ps                               {find ID of running container}
   docker commit ID mysnapshot             {create a snapshot}
   docker run -t -i mysnapshot /bin/bash   {run a bash shell}
                                           {-i interactive, -t terminal}
 
Building/Running a Container {containing python code}
   docker build -t {name} .
   docker  run -i -t {name} python run.py
 
Deleting Images
   docker image list      {list images}
   docker rmi image_ID.   {remove image}
 
   If you are unable to delete due to container in use
      docker ps                   {get container name}
      docker rm container_name    {remove exited container}
      docker rmi image_id         {remove image}
 
Mounting Local File Systems
This will mount the current directory as /mnt/app for the container to access:
    docker run -it -v ${PWD}:/mnt/app instabot /bin/bash
 
Docker Documentation
 
 
This entry was posted in Code, Docker. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *