Skip to content
alex [dot] kramer [at] g_m_a_i_l [dot] com edited this page Jun 26, 2018 · 15 revisions

Images

Build image from Dockerfile, skip cache, with name and tag:

docker build --no-cache -t [NAME]:[TAG] [PATH TO DOCKERFILE]

Pull image from Docker Hub:

docker pull [REMOTE IMAGE NAME]

List all local images:

docker images

Inspect:

docker inspect [IMAGE NAME|ID]

History:

docker history [IMAGE NAME|ID]

Delete:

docker rmi [IMAGE NAME|ID]

Containers

Create container from image and start it backgrounded with mapped port (necessary for OSX) and mounted directory:

docker run -d -p [HOST PORT]:[CONTAINER PORT] --mount type=bind,source=[HOST DIR PATH],target=[CONTAINER DIR PATH] [IMAGE NAME|ID]

List containers:

docker ps -a # all containers
docker ps --format "{{.Names}}" # running containers by name
docker ps -q # running containers by id

Bash shell for a running container:

docker exec -it [CONTAINER NAME|ID] bash

Start/stop container:

docker start [CONTAINER NAME|ID]
docker stop [CONTAINER NAME|ID]

List running containers by name or id:

docker ps --format "{{.Names}}" # name
docker ps -q # id

Delete:

docker rm [CONTAINER NAME|ID]

Clone this wiki locally