Table of Contents generated with DocToc
In a directory with a Dockerfile:
docker build -t <image_name>[:<image_tag>] .
Build behind a proxy :
docker build -t <image_name>[:<image_tag>] --build-arg http_proxy=<proxy_url> --build-arg https_proxy=<proxy_url> .
Create a container from a CentOS 7 image and run a Bash shell
docker run -it centos:7 /bin/bash
Options:
- -i : interactive mode, keep STDIN open
- -t : associate a pseudo TTY
Detach from a running container : CTRL+p+q
Attach to a running container:
docker attach <container-id>
Docker uses 172.17.0.0 for the docker0 interface.
When creating networks Docker increments the subnet (172.18, 172.19...). If your local network is on the 172.x.y.z subnet it will may conflict at some point in time with a docker bridge.
To solve this issue you can create a network manually like in the following example
docker network create --subnet 192.168.1.0/24
Or define the network in your docker-compose file
networks:
default:
driver: bridge
ipam:
driver: default
config:
- subnet: 192.168.2.0/24
Remove dangling containers
docker container prune
docker volume prune
or
docker volume rm $(docker volume ls -f dangling=true -q)
docker image prune
or
docker rmi $(docker images -q -f dangling=true)
Windows tip for Cygwin shell configuration, put the following code in .zshrc, .bashrc...:
eval $(docker-machine env default)
export no_proxy=$no_proxy,$(docker-machine ip default)
Create the default VM with the following command:
docker-machine create -d virtualbox \
--engine-env HTTP_PROXY=[proxy_url] \
--engine-env HTTPS_PROXY=[proxy_url] \
--engine-env NO_PROXY=localhost \
default
Example for 50GB disk (default value: 20GB)
docker-machine create -d virtualbox \
--virtualbox-disk-size 50000 \
default