Skip to content

Instantly share code, notes, and snippets.

@basus
Created September 13, 2018 18:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save basus/7feb0a8204e00f81b74744e7ba1c358b to your computer and use it in GitHub Desktop.
Save basus/7feb0a8204e00f81b74744e7ba1c358b to your computer and use it in GitHub Desktop.
Docker shortcuts
# Start a container from an image, daemonized, with port forwarding.
# This runs whatever CMD the image is set to run.
docker run -d -p 8000:8000 <image name>
# Run a bash shell in a already-running container.
# Exiting this shell will stop the container.
docker exec -it <container name/id> bash
# Restart the container. This is required after exiting a shell running
# on it via the above command. This is also required if a container is
# explicitly stopped using the container below.
docker restart <container name/id>
# Stop the container.
docker stop <container name/id>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment