yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum install docker-ce-17.12.0-ce
systemctl start docker
docker run hello-world
mkdir -p /etc/systemd/system/docker.service.d
touch /etc/systemd/system/docker.service.d/http-proxy.conf.test
cat >> /etc/systemd/system/docker.service.d/http-proxy.conf.test <<EOF
[Service]
Environment="HTTP_PROXY=http://193.56.47.20:8080/"
Environment="HTTPS_PROXY=http://193.56.47.20:8080/"
Environment="NO_PROXY=.frml.bull.fr"
EOF
systemctl daemon-reload
systemctl restart docker
systemctl show --property=Environment docker
yum remove docker-cerm -rf /var/lib/docker
curl -L https://github.com/docker/compose/releases/download/1.21.2/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
docker-compose --version
rm /usr/local/bin/docker-compose
Pour la configuration du proxy sur un serveur Linux ayant docker 17.07 au minimum d’installee, il faut cree le fichier suivant : ~/.docker/config.json
{
"proxies":
{
"default":
{
"httpProxy": "http://127.0.0.1:8080",
"httpsProxy": "https://127.0.0.1:8080",
"noProxy": "*.frmp.bull.fr,.epsi.fr"
}
}
}
Sinon il faut utiliser les variables d’environment :
| Variable | Dockerfile exemple | docker run exemple |
|---|---|---|
| HTTP_PROXY | ENV HTTP_PROXY “http://127.0.0.1:8080” | –env HTTP_PROXY=“http://127.0.0.1:8080” |
| HTTPS_PROXY | ENV HTTPS_PROXY “https://127.0.0.1:8080” | –env HTTPS_PROXY=“https://127.0.0.1:8080” |
| FTP_PROXY | ENV FTP_PROXY “ftp://127.0.0.1:8080” | –env FTP_PROXY=“ftp://127.0.0.1:8080” |
| NO_PROXY | ENV NO_PROXY “*.test.example.com,.example2.com” | –env NO_PROXY="*.test.example.com" |
Source : https://docs.docker.com/network/proxy/#configure-the-docker-client
Il faut renseigner à l’host les variables d’environnements suivant pour le dépôt docker :
/etc/systemd/system/docker.service.d/http-proxy.conf
[Service]
Environment="HTTP_PROXY=http://8.8.8.8:8080/"
Environment="HTTPS_PROXY=http://8.8.8.8:8080/"
Environment="NO_PROXY=.example.fr"
On peut configurer des variables d’environnements dans un fichier nommee .env afin de faciliter la construction et la lecture d’un docker-compose.
On peut retrouver nos chemins absolus par exemple :
.env :
SOURCE_FILE=/etc/httpd
VERSION=v2.4
On peut définir des fichiers qui ne seront pas pris en compte dans le build.context pour la création d’image.
# comment
*/temp*
*/*/temp*
temp?
| Règles | Description |
|---|---|
# comment | ignorer |
*/temp* | Exclure les fichiers et répertoires dont les noms commencent par temp dans n’importe quel sous-répertoire immédiat de la racine. Par exemple, le fichier brut /somedir/temporary.txt est exclu, tout comme le répertoire /somedir/temp . |
*/*/temp* | Exclure les fichiers et les répertoires commençant par temp de n’importe quel sous-répertoire situé à deux niveaux sous la racine. Par exemple, /somedir/subdir/temporary.txt est exclu. |
temp? | Exclure les fichiers et les répertoires dans le répertoire racine dont les noms sont une extension d’un caractère de temp . Par exemple, /tempa et /tempb sont exclus. |
Pour crée la socket TCP afin d’intérroger au travers du client docker un DOCKER_HOST présent sur un autre serveur, on crée le fichier /etc/docker/daemon.json :
{
"debug": true,
"hosts": [“unix:///var/run/docker.sock”,”tcp://0.0.0.0:2375”],
"log-level": "Warn"
}
source des options : https://docs.docker.com/engine/reference/commandline/dockerd/#daemon-configuration-file
Ensuite on indique ce nouveau fichier de configuration au service docker. Pour cela il faut modifier le fichier suiivant : /etc/systemd/system/multi-user.target.wants/docker.service
On ajoute les lignes suivantes :
EnvironmentFile=-/etc/docker/daemon.json
ExecStart=/usr/bin/dockerd
Ensuite on redémarre le service docker :
systemctl restart docker
On ajout deux lignes cluster afin de contacter l’orchestrateur docker (Racnher, Kubernetes, Swarm,…) avec son adresse IP, son port et le répertoire des clés. Ensuite l’interface à utiliser pour communiquer avec avec l’orchestrateur avec le port 2376 pour SSL/TLS sinon 2375.
vi /etc/docker/daemon.json
{
"debug": true,
"hosts": [“unix:///var/run/docker.sock”,”tcp://0.0.0.0:2375”],
"log-level": "Warn"
"cluster-store":"consul://192.168.99.100:8500/network",
"cluster-advertise":"eth1:2376"
}
vi /etc/docker/daemon.json
{
"debug": true,
"hosts": [“unix:///var/run/docker.sock”,”tcp://0.0.0.0:2375”],
"log-level": "Warn"
"cluster-store":"consul://192.168.99.100:8500/network",
"cluster-advertise":"eth1:2376"
"insecure-registries":["192.168.99.100:5000"]
}
vi /etc/docker/daemon.json
{
"debug": true,
"hosts": [“unix:///var/run/docker.sock”,”tcp://0.0.0.0:2375”],
"log-level": "Warn"
"cluster-store":"consul://192.168.99.100:8500/network",
"cluster-advertise":"eth1:2376"
"insecure-registries":["192.168.99.100:5000"]
"bip": "192.168.40.1/24",
"fixed-cidr": "192.168.40.1/24"
}
Attention dans il faut crée un réseau spécifique pour l’utilisation de cette configuration dans un docker compose.
docker network create --subnet=192.168.41.0/24 example_41
version: '3'
networks:
default:
external:
name: example_41