DevOps ~ Docker Commands - rohit120582sharma/Documentation GitHub Wiki
Image based command
Building an image from a Docker file
# -t: to tag the image name# -f: to configure the file path
$ Docker build -t myapp -f ./Dockerfile .
Listing all images that are locally stored
$ docker images
Removing named image
$ docker rmi <image-name>
Removing unnamed images
$ docker rmi $(docker images -q -f dangling=true)
Container based command
Creating and starting a container from an image
# --name: to tag the container name# -it: to make an interaction with a container# -d: to detach a container on start# -p: to publish the host IP and the host port to the container port# -v: to define and share the volume across containers
$ docker run <image-name>
$ docker run --name <container-name> -p 3000:3000 <image-name>
$ docker run -it <image-name> sh
Listing running containers/processes
$ docker ps
Listing running and stopped containers
$ docker ps -a
$ docker ps --all
Container lifecycle. These two commands are equivalent to 'docker run' command
$ docker create <image-name># It returns a newly created <container-id>
$ docker start -a <container-id>