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

Docker

Containers

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

docker run -d -p [HOST PORT]:[CONTAINER PORT] [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]

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]

History:

docker history

Clone this wiki locally