Welcome to Scribd!
Academic Documents
Professional Documents
Culture Documents
Hobbies & Crafts Documents
Personal Growth Documents
Docker Cheatsheet
bash docker logs docker stop docker restart docker rm docker port docker top docker kill nginx - The image to use {style-none} Description List running containers List all containers List running containers (with CPU/ memory) List all images Connecting to container Shows container’s console log Stop a container Restart a container Remove a container Shows container’s port mapping List processes Kill a container Parameter can be container id or name Containers Starting & Stopping htpsgis github con/Rany#080/806a00578120aa5e05e9094170772089 2872024 Description docker start nginx-server docker stop nginx-server docker restart nginx-server docker pause nginx-server docker unpause nginx-server docker wait nginx-server docker kill nginx-server docker attach nginx-server Information Example docker ps docker ps -a docker logs nginx-server docker inspect nginx-server docker events nginx-server docker port nginx-server docker top nginx-server docker stats nginx-server docker diff nginx-server Creating docker create [options] IMAGE -a, --attach “i, --interactive ot, --tty =-name NAME =P, --publish 5000:5000 htpsgis github con/Rany#080/806a00578120aa5e05e9094170772089 # # # # # cocker cheatsheet GikuD Example Starting Stopping Restarting Pausing Unpausing Blocking a Container Sending a SIGKILL Connecting to an Existing Container Description List running containers List all containers Container Logs Inspecting Containers Containers Events Public Ports Running Processes Container Resource Usage Lists the changes made to a container. attach stdout/err attach stdin (interactive) pseudo-tty name your image port map (host: container) aerirr02 ocker cheatsheet - Giub --expose 5432 4 expose a port to containers P, --publish-all # publish all ports <-Link container:alias # linking -v, --volume ~pwd™:/app # mount (absolute paths needed) ~e, --env NAME=hello # env vars Example $ docker create --name my_redis --expose 6379 redis:3.0.2 Manipulating Renaming a Container docker rename my-nginx nginx-server Removing a Container docker rm nginx-server Updating a Container docker update --cpu-shares 512 -m 300M nginx-server Images Manipulating Exanple docker images docker rmi nginx docker load < ubuntu.tar.gz docker load --input ubuntu.tar docker save busybox > ubuntu.tar docker history Description Listing images Removing an image Loading a tarred repository Loading a tarred repository Save an image to a tar archive Showing the history of an image hitpsgis github con/Rancy#080/806a00578120aa5e05a90941707 72059 48rirr02 ocker cheatsheet Gitub Example Description docker conmit nginx Save a container as an image. docker tag nginx eoné1/nginx Tagging an image docker push eond1/nginx Pushing an image Building Images $ docker build . $ docker build $ docker build $ docker build $ docker build $ docker build $ curl exanple. Networking Manipulating github.con/creack/docker-Firefox ~ < Dockerfile ~ < context. tar.gz -t eon/nginx-server -f myOtherDockerfile . con/renote/Dockerfile | docker build -f - . Removing a network docker network Listing networks docker network Pm MyOverlayNetwork 1s Getting information about a network docker network inspect MyOverlayNetwork Connecting a running container to a network docker network connect MyOverlayNetwork nginx Connecting a container to a network when it starts htpsgis github con/Rany#080/806a00578120aa5e05e9094170772089rirr02 ocker cheatsheet - Giub docker run -it -d --network=MyOverlayNetwork nginx Disconnecting a container from a network docker network disconnect MyOverlayNetwork nginx Creating Networks docker network create -d overlay MyOverlayNetwork docker network create -d bridge MyBridgeNetwork docker network create -d overlay \ --subnet=192.168.0.0/16 \ --subnet=192.178.0.6/16 \ --gateway=192.168.0.108 \ ~-gateway=192.178.0.188 \ =-ip-range=192.168.1.2/24 \ =-aux-address="ny-router=192.168.1.5" \ =-aux-address="ny-switch=192.168.1.6" \ ~-aux-address="ny-printer=192.170.1.5" ~-aux-address="ny-nas=192.17@.1.6" \ MyOverlayNetwork Miscellaneous Docker Hub Docker Syntax docker search search_word docker pull user/image docker login docker push user/image Registry commands Login to a Registry htpsgis github con/Rany#080/806a00578120aa5e05e9094170772089 Description Search docker hub for images. Downloads an image from dacker hub. Authenticate to docker hub Uploads an image to docker hub. oerirr02 ocker cheatsheet - Giub $ docker login $ docker login localhost:8080 Logout from a Registry $ docker logout $ docker logout localhost : 8680 Searching an Image $ docker search nginx $ docker search nginx --stars=3 --no-trunc busybox Pulling an Image $ docker pull nginx $ docker pull eon@1/nginx localhost :5000/myadmin/nginx Pushing an Image $ docker push eondt/nginx $ docker push eond1/nginx localhost:5000/nyadmin/nginx Batch clean Example Description docker stop -f $(docker ps -a -q) Stopping all containers docker rm -f $(docker ps -a -q) Removing all containers docker rmi -f $(docker images -q) Removing all images Volumes Check volumes $ docker volume 15 htpsgis github con/Rany#080/806a00578120aa5e05e9094170772089 18rirr02 ocker cheatsheet - Giub Cleanup unused volumes $ docker volume prune hitpsgist github con/Rany#080/806a00578120aa5e0529094170772059 ae