Skip to content

Instantly share code, notes, and snippets.

@deibit
Last active December 10, 2019 21:43
Show Gist options
  • Save deibit/2064fd346a4da83c4059275ee5c4458d to your computer and use it in GitHub Desktop.
Save deibit/2064fd346a4da83c4059275ee5c4458d to your computer and use it in GitHub Desktop.
Docker cookbook
- Open an interactive session into a container
docker exec -it <containder_name> /bin/bash
(/bin/bash or whatever command you want to execute)
- Running a container in a specific network with a network alias (so we can reference this name in other containers):
docker run --name <container_name> --net <network_name> --net-alias <container_netname> -d <image>
- Specify a network in docker-compose file:
networks:
default:
external:
name: <network_name>
- Create a network:
docker network create <network_name>
- List containers:
docker ps
docker container ls
- List images:
docker images
docker image ls
- Save a container as an image:
docker commit <options> <image_name>
- Live statistics:
docker stats
- Import/export:
$ mongodump
$ mongoimport
$ mongorestore
- Copying files from a container
docker cp <container_name>:path_inside_container host_path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment