In My Words
"Docker automates the repetitive tasks of setting up and configuring multiple (dev/qa/prod) environments so that developers can focus on what matters: building great software"
"Docker automates the repetitive tasks of setting up and configuring multiple (dev/qa/prod) environments so that developers can focus on what matters: building great software"
Listing containers
# List running containers
docker ps
# List all containers
docker ps -a
Starting/Stopping containers
# Start
docker start containerName
# Stop
docker stop containerName
Removing containers
# Remove container
docker rm containerName
# Stop and remove container
docker rm -f containerName
# Remove all exited containers
docker rm -v $(docker ps -a -q -f status=exited)
Running commands in new containers
docker run imageName command arguments
# Example
docker run docker/whalesay cowsay Hello
# Assign a name to the container
docker run --name myName docker/whalesay cowsay Hello
# Run with a specific tag of an image
docker run node:6.9.1 node --version
# Run container in background
docker run -d -p 80:80 --name webserver nginx
See Docker run reference for more …Images
Listing local images
docker images
Removing images
docker rmi imageName
# Remove unwanted dangling images
docker rmi $(docker images -f "dangling=true" -q)
Searching for images
# Search the Docker Hub for images
docker search searchWord
Pulling images
docker pull imageName
# Pull a specific tag
docker pull imageName:tag
# Example: Get a specific node version
docker pull node:6.9.1
Building image from Dockerfile
docker build .
# Name the image
docker build -t imageName .
# Tag the image
docker build -t imageName:1.0.0 .
Docker Swarm Cluster Creation
PS C:\windows\system32> docker swarm init --advertise-addr 10.79.124.174
Swarm initialized: current node (x6ekx7h660cg8nkneujs0n0jf) is now a manager.
To add a worker to this swarm, run the following command:
docker swarm join --token SWMTKN-1-04osgsy3kig1sdzl0q13w7sw5964515jt6c9dkqvjzsk6tntne-1ascqzq63u3gd6xrmp3qzk8ew 10.7
9.124.174:2377
To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.