Last active
June 1, 2021 05:52
-
-
Save urbansky/35763b97931718f51a61f5ccc86cac05 to your computer and use it in GitHub Desktop.
Docker common commands
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# --------------------------------------------------------- | |
# 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 new docker container from image, in the current shell | |
# if you close the shell the container will be stopped | |
docker run mongo | |
# Run a new docker container from, 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 | |
# Starts a existing container | |
docker start | |
# 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 | |
# Shell into an image | |
docker run --rm -it --entrypoint=/bin/bash imageName | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment