Skip to content

Instantly share code, notes, and snippets.

@vishnun
Created April 22, 2017 06:04
Show Gist options
  • Save vishnun/e2ad47ce2856b16450313b5aced96d13 to your computer and use it in GitHub Desktop.
Save vishnun/e2ad47ce2856b16450313b5aced96d13 to your computer and use it in GitHub Desktop.
docker commands

Remove exited containers:

sudo docker rm $(docker ps -a -q -f status=exited)

List all docker containers

sudo docker ps -a

Run docker container in interactive mode (execute shell of the container busybox for eg):

docker run -it busybox sh

Execute a single command for a container (busybox)

project docker run busybox echo "hello from busybox"

Download a docker image from the registry

docker run prakhar1989/static-site

Execute in -d (detached) mode -P (publish all the exposed ports) --name (just the name we want to give)

docker run -d -P --name static-site prakhar1989/static-site

To see the ports:

docker port static-site

specify port through which the container will forward the traffic

docker run -p 8888:80 prakhar1989/static-site
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment