Docker Commands
basics enough to sail in the open seas
$ docker pull <image>
docker pull:
pull images from a docker
repository. Ex: docker hub
$ docker run <image>
docker run:
creates a container from an
image, might be already on the
local machine.
If not, will pull it from docker hub
It basically, {pull, start} in one
package.
$ docker start <container>
docker start:
start one or more stopped
container
$ docker stop <container>
docker stop:
stop a running container
$ docker images
docker images:
list all the locally stored docker
images
$ docker ps
$ docker ps -a
docker ps:
list all running containers
ps option -a :
list all running/stopped containers
$ docker logs <container>
docker logs:
fetchs logs of a container
$ docker exec -it <container>
docker exec:
create shell/bash (based on the
image) session in the container
$ docker rm <container>
docker rm:
deletes a stopped container
$ docker rmi <image>
docker rmi:
deletes image on your machine
$ docker run -d \
> -p <hostport> : <containerPort> \
> -e <env variable> \
> --net <docker-network> \
> -name <name of container> \
> <image>
docker popular options:
-d: run the container in the detach mood.
-p: maps the container port to the host port.
-e: specify an environment variable.
--net: specify a docker network to run in.
--name: gives the container a name instead
of using container ID
Congratulations
We just hit the shore