Skip to content

Instantly share code, notes, and snippets.

@lokisho
Last active March 10, 2020 04:25
Show Gist options
  • Save lokisho/8b1b8e9224ebfee23aec21c991a19974 to your computer and use it in GitHub Desktop.
Save lokisho/8b1b8e9224ebfee23aec21c991a19974 to your computer and use it in GitHub Desktop.
Docker commands
docker container run --publish[allow to listen] 8080:80[host_port:container_port] --name[optional for listing] webhost -d[detached] nginx:1.11[optional image version] nginx [image]
--env [to pass environment variables]
docker container logs [to view the logs of the container, useful to get mysql password for example]
docker container stop NAME [stops container, space separated to stop multiple containers]
docker container ls [list containers] -a [all]
docker container top [process list in one container]
docker container inspect <name|id>[details of one container config]
docker container stats [performance stats for all containers]
docker container exec -it [run additional command in existing container]
docker container run -it [run additional command in existing container] ex docker container run -it nginx bash[to get the bash command]
docker container port <container> Quick port check
docker container inspect --format '{{ .NetworkSettings.IPAddress }}' <container> [get the container IP Address]
NETWORKING
docker network ls
docker network inspect <network>
docker network create --driver
docker network connect
docker network disconnect
IMAGES
docker image history <image>
docker image inspect <image>
docker image tag <src_image> <target_image> [docker image mysql lokisho/mysql][docker image lokisho/mysql lokisho/mysql:experimental]
docker login
docker logout
docker image push
docker image prune [to clean up just "dangling" images]
docker system prune [will clean up everything]
docker image prune -a [which will remove all images you're not using]
docker system df [to see space usage.]
docker-machine rm default [Delete the linux vm if you are using Docker Tools. Vm won't auto shrink]
docker-machine create [to create it again]
docker volume ls
docker volume inspect <volume>
docker container run <image> -v <name>:<path> creates a named container
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment