Docker on CentOS 7

Installation

$ yum install docker
$ systemctl enable docker
$ systemctl start docker

Configuration

Autorisation d'un utilisateur lambda

gpasswd -a docker francois

Utilisation

Liste des images

docker images

Créer sa propre image de base

curl --insecure -O https://raw.githubusercontent.com/docker/docker/master/contrib/mkimage-yum.sh

Apport de modifications.

Exemple d'utilisation de docker

docker run --rm -i -t --name test -w /tmp -v /home/depots/ISO:/ISO --privileged=true -e TOTO=TOTO centos-bare:6.6  ls -al /ISO

Si on ne veut pas mettre de privilège, il faut mettre à jour selinux en analysant les blocages à al'aides des commandes audit2why et audit2allow

chcon -Rt svirt_sandbox_file_t /path/to/volume

Liens externes

Docker

docker build -t friendlyhello .  # Create image using this directory's Dockerfile
docker run -p 4000:80 friendlyhello  # Run "friendlyname" mapping port 4000 to 80
docker run -d -p 4000:80 friendlyhello         # Same thing, but in detached mode
docker container ls                                # List all running containers
docker container ls -a             # List all containers, even those not running
docker container stop <hash>           # Gracefully stop the specified container
docker container kill <hash>         # Force shutdown of the specified container
docker container rm <hash>        # Remove specified container from this machine
docker container rm $(docker container ls -a -q)         # Remove all containers
docker image ls -a                             # List all images on this machine
docker image rm <image id>            # Remove specified image from this machine
docker image rm $(docker image ls -a -q)   # Remove all images from this machine
docker login             # Log in this CLI session using your Docker credentials
docker tag <image> username/repository:tag  # Tag <image> for upload to registry
docker push username/repository:tag            # Upload tagged image to registry
docker run username/repository:tag                   # Run image from a registry