Skip to content

Instantly share code, notes, and snippets.

@ftabashir
Created October 1, 2019 17:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ftabashir/deca85952f0e3a5bce42e3019d0ea6ca to your computer and use it in GitHub Desktop.
Save ftabashir/deca85952f0e3a5bce42e3019d0ea6ca to your computer and use it in GitHub Desktop.
#gives you details on the installed version of Docker
docker version
#runs a container from the image (if it has not a copy of the image in its cache, will download it beforehand)
docker container run hello-world
#getting a list of running containers
docker container ls
#getting a list of all containers
docker container ls --all
docker container run --detach --publish 80:80 nginx:alpine
#--publish host_port:container_port
#--detach runs container in background
docker container run --interactive --tty ubuntu:16.04
docker pull node:8.12-alpine
docker image ls
docker image rm
docker run --name <container-name> node:8.12-alpine
docker ps -a
docker rm <container-name>
docker run -it --name dnode node:8.12-alpine sh
docker start dnode
docker stop dnode
docker restart dnode
docker inspect
docker exec -it dnode sh
# create two interactive containers with a network
docker rm dnode1 dnode2
docker run --net dnodes --name dnode1 -it node:8.12-alpine sh
docker run --net dnodes --name dnode2 -it node:8.12-alpine sh
#create image with dockerfile
cd <your-dockerfile-directory>
docker build --no-cache --tag express:1 .
docker image ls
docker run --name express1 --publish 4000:3000 express:1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment