vendredi 27 mars 2020

Docker campaign

My notes to startup docker:

Configure your internal docker repository

Find your internal Trusted Repository
dtr.mycompany.com

In your : /etc/docker/daemon.json file

Make sure that you trust your repository:
{
    "insecure-registries" : ["dtr.mycompany.com"]
}

curl -k https://dtr.mycompany.com/ca -o /usr/local/share/ca-certificates/dtr.mycompany.com.crt
update-ca-certificates
service docker restart

Allow the user (not root to use docker)

usermod -aG docker myuser
su - myuser
newgrp

Create a docker file

Create the docker file

FROM  dtr.mycompany.com/mycompany/httpd:latest
LABEL maintainer="clement_soullard@infosys.com"
EXPOSE 80
COPY dist/ui  /usr/local/apache2/htdocs/
COPY docker/certs/server.crt /usr/local/apache2/conf/
COPY docker/certs/server.key /usr/local/apache2/conf/
COPY docker/httpd.conf /usr/local/apache2/conf/httpd.conf
RUN sed -i \
        -e 's/^#\(Include .*httpd-ssl.conf\)/\1/' \
        -e 's/^#\(LoadModule .*mod_ssl.so\)/\1/' \
        -e 's/^#\(LoadModule .*mod_socache_shmcb.so\)/\1/' \
        conf/httpd.conf

Useful commands

Stopping a container

docker stop specworks-ui

Removing a container

docker rm specworks-ui
docker image build -t specworks-ui:1.0 .
docker container run --publish 8000:80 --detach --name specworks-ui specworks-ui:1.0
docker exec -it specworks-ui  bash

docker network create -d bridge specworks-net

cp commands works recursively
docker cp docker/httpd.conf specworks-ui:/usr/local/apache2/conf/httpd.conf

Clean up the docker cache

docker system prune -a -f 

Download image from proxy 

mkdir /etc/systemd/system/docker.service.d
Now create a file called /etc/systemd/system/docker.service.d/http-proxy.conf that adds the HTTP_PROXY environment variable:
[Service]
Environment="HTTP_PROXY=http://proxy.example.com:80/"
If you have internal Docker registries that you need to contact without proxying you can specify them via the NO_PROXY environment variable:
Environment="HTTP_PROXY=http://proxy.example.com:80/"
Environment="NO_PROXY=localhost,127.0.0.0/8,docker-registry.somecorporation.com"
Flush changes:
$ sudo systemctl daemon-reload
Verify that the configuration has been loaded:
$ sudo systemctl show --property Environment docker
Environment=HTTP_PROXY=http://proxy.example.com:80/
Restart Docker:
$ sudo systemctl restart docker