Last active
March 7, 2017 01:18
-
-
Save worldofprasanna/22b4b12b70058beeb4a76ff833c74a83 to your computer and use it in GitHub Desktop.
Docker useful 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
Reference: https://prakhar.me/docker-curriculum/#busybox | |
# Run a static website in background. d - detach mode, P - expose all ports, --name give name to the running container | |
docker run -d -P --name static-site prakhar1989/static-site | |
# To see the ports used | |
docker port static-site | |
# Docker networks | |
``` | |
By default, all containers are ran in bridge network. | |
We can create our own network and run containers in that network. | |
So that containers within the same network can easily communicate with each other, using the name. | |
``` | |
# list network | |
docker network ls | |
# to start network | |
docker network create foodtrucks | |
# Start containers in same network | |
docker run -d --net foodtrucks -p 5000:5000 --name foodtrucks wordofprasanna/foodtrucks | |
docker run -dp 9200:9200 --net foodtrucks --name es elasticsearch | |
# to remove network | |
docker network rm foodtrucks | |
# Docker compose | |
``` | |
multi container environments | |
instead of dealing at the container level, it enables to deal at the app level | |
yml specification | |
creates: | |
- container | |
- network | |
service discovery is done through DNS Server, instead of changing /etc/hosts | |
``` | |
docker-compose up -d | |
docker-compose stop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment