Last active
August 16, 2019 00:56
-
-
Save rcanepa/e45eebc3af58c66497380421d9a3fcf4 to your computer and use it in GitHub Desktop.
Docker cli commands
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker build -t friendlyname . # Create image using this directory's Dockerfile | |
docker run -p 4000:80 friendlyname # Run "friendlyname" mapping port 4000 to 80 | |
docker run -d -p 4000:80 friendlyname # Same thing, but in detached mode | |
docker container ls # List all running containers | |
docker container ls -a # List all containers, even those not running | |
docker container stop <hash> # Gracefully stop the specified container | |
docker container kill <hash> # Force shutdown of the specified container | |
docker container rm <hash> # Remove specified container from this machine | |
docker container rm $(docker container ls -a -q) # Remove all containers | |
docker image ls -a # List all images on this machine | |
docker image rm <image id> # Remove specified image from this machine | |
docker image rm $(docker image ls -a -q) # Remove all images from this machine | |
docker login # Log in this CLI session using your Docker credentials | |
docker tag <image> username/repository:tag # Tag <image> for upload to registry | |
docker push username/repository:tag # Upload tagged image to registry | |
docker run username/repository:tag # Run image from a registry | |
docker stack ls # List stacks or apps | |
docker stack deploy -c <composefile> <appname> # Run the specified Compose file | |
docker service ls # List running services associated with an app | |
docker service ps <service> # List tasks associated with an app | |
docker inspect <task or container> # Inspect task or container | |
docker container ls -q # List container IDs | |
docker stack rm <appname> # Tear down an application | |
docker swarm leave --force # Take down a single node swarm from the manager | |
docker container run -d --name nginx -p 80:80 -v $(pwd):/usr/share/nginx/html nginx # Bind mounting (share host volume with the container) | |
docker container run -d --name mysql -e MYSQL_ALLOW_EMPTY_PASSWORD=True -v mysql-db:/var/lib/mysql mysql # Use a named volumen |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment