Docker
Installation:
TODO: Add installation steps here
Basic Commands
docker login
- To login to your DockerHub Accountdocker images
- List all the local Imagesdocker logs <container_id>
- View the logs/stdout of a containerdocker logs -f <container_id>
- Follow the logs/stdout of a containerdocker run
– Runs new container.docker start
– Starts one or more stopped containersdocker stop
– Stops one or more running containersdocker build
– Builds an image form a docker filedocker pull
– Pulls an image or a repository from a registrydocker push
– Pushes an image or a repository to a registrydocker export
– Exports a container’s filesystem as a tar archivedocker exec
– Runs a command in a run-time containerdocker search
– Searches the docker Hub for imagesdocker attach
– Attaches to a running containerdocker commit
– Creates a new image from a container’s changesdocker ps
- Lists all the containersdocker ps -a
- Lists all the active containersdocker stats
- Show stats of all running containers
Running Container:
Run a container and attach - docker run -it <image_name>
Run a container and detach - docker run -d <image_name>
Run a container and open a port - docker run -it -p <host_port>:<container_port> <image_name>
Run a container and pass environment variable - docker run -e ENV1=value1 --env ENV2=value2 --env-file ./env.prod <image_name>
Run a container and limit memory and cpu - #TODO: Add command here
Run a container and remove it once execution is completed - #TODO: Add command here
Run a container and mount a host volume - docker run -it -v <host_volume_path>:<container_volume_path> <image_name>
Run a container with a custom name - docker run -it --name <unique_name> <image_name>
Dockerfile
TODO: Add dockerfile terminologies here
Docker Bash Aliases
1 2 3 4 5 6 7 8 9 10 11 | alias dr='docker run $1' alias di='docker images $1' alias drm='docker rm $1' alias drmi='docker rmi $1' alias dl='docker ps' alias dll='docker ps -a' alias ds='docker stats' alias dsi='docker stats $1' function db() { docker build -t "$1" .; } |
TODO: Add dockerfile bash aliases here