Curated while getting started with Docker
docker login
docker run hello-world
docker build -t NAME-OF-APP
-
docker run -p 4000:80 NAME-OF-APP
visit
http://localhost:4000
-
docker run -p 80:80 USERNAME/REPO:TAG
visit
http://localhost/
Get container info
docker ps
after running the app, will list port
Can also get port info via
docker port CONTAINER-ID
ordocker port CONTAINER-NAME
docker run -d -p 4000:80 NAME-OF-APP
docker stop CONTAINER-ID
docker images
docker push USERNAME/REPO:TAG
docker run -p 4000:80 USERNAME/REPO:TAG
docker tag image USERNAME/REPO:TAG
// Copy new/updated docker-compose.yml file before deploying the new/updated version
-
docker-machine scp docker-compose.yml VM-NAME:~
-
docker stack deploy -c docker-compose.yml NAME-OF-APP
Run
docker swarm init
once before if it has not been done yet
docker stack ps NAME-OF-APP
docker stack rm NAME-OF-APP
docker swarm leave --force
docker-machine create --driver virtualbox VM-NAME
docker-machine env VM-NAME
Only a swarm manager can execute Docker commands
docker-machine ssh VM-NAME "docker swarm init"
docker-machine ssh
is a command that enables sending commands to a specified VM- If error with need to use
--advertise-addr
, thendocker-machine ssh VM-NAME "docker swarm init --advertise-addr VM-IP:2377"
docker-machine ls
to find IP for appropriate VM-IP;
Specifying port has to be
2377
Add worker to a swarm
Workers are for capacity and are not able to execute Docker commands
docker-machine ssh VM-NAME "docker swarm join --token <token>"
make sure specifying port is
2377
docker-machine ssh VM-NAME
THEN in the machine, then run 'docker node ls' THEN to exit with command exit
Alternatively, docker-machine ssh VM-NAME "docker node ls"
docker-machine ssh VM-NAME "docker swarm leave"
docker-machine scp docker-compose.yml VM-NAME:~
docker-machine ssh VM-NAME "docker stack deploy -c docker-compose.yml NAME-OF-APP"
Check via docker-machine ssh VM-NAME "docker stack ps NAME-OF-APP"
docker-machine ls
docker-machine ssh VM-NAME "docker stack rm NAME-OF-APP"
Can choose to keep the swarm or remove it
Run docker-machine ls
to get IP address of one of nodes
In this version, visualizer runs on port 8080, so visit either IP address at this port.