Skip to content

Instantly share code, notes, and snippets.

@urbansky urbansky/docker.sh
Last active Jan 24, 2019

Embed
What would you like to do?
Docker common commands
# ---------------------------------------------------------
# docker file -> text file with commands to create an image
# images -> a read-only memory dump
# container -> running or stopped image with working data
# ---------------------------------------------------------
# see also: https://github.com/wsargent/docker-cheat-sheet
# List all running docker containers
docker ps
# List all docker containers, including the stopped containers
docker ps -a
# Run a docker container, in the current shell
# if you close the shell the container will be stopped
docker run mongo
# Run a docker container, in the background
docker run -d mongo
# Map host port to container port and giv environment variable
docker run -p 27017:27017 -e PASSWORD=password mongo
# Show logs
docker logs b6e69efb94f3
# Stop a docker container, use the container id (see 'docker ps')
docker stop b6e69efb94f3
# List all images
docker images -a
# Remove image
docker rmi b6e69efb94f3
# Build a docker image from docker file in the current directory
docker build -t tagname
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.