doc/docker.md
ma.azimi@laposte.net 8948d4978e Update docker.md
2015-04-12 23:12:03 +02:00

2.4 KiB

Docker and YunoHost

Here is a small memo-documentation page on how to test/develop YunoHost with Docker.

Find other ways to install YunoHost here.


Install Docker

Pre-requisite: a x86 computer under Ubuntu 14.04 (or above), or ArchLinux.

On Ubuntu :

curl -s https://get.docker.io/ubuntu/ | sudo sh

On ArchLinux :

sudo pacman -Sy docker

Note: you may have to start Docker's daemon manually (as root: service docker start, systemctl start docker or simply docker -d)


Build the YunoHost container

The following command will fetch the latest YunoHost built image:

docker pull yunohost/full

You can also build the image manually:

docker build -t yunohost/full github.com/YunoHost/Dockerfile

You can check that the container is successfully built with the docker images command.


Run the container

docker run -d yunohost/full /sbin/init

If you want to run the container and forward all the interesting ports to the host:

docker run -d \
 -p 25:25 \
 -p 53:53/udp \
 -p 80:80 \
 -p 443:443 \
 -p 465:465 \
 -p 993:993 \
 -p 5222:5222 \
 -p 5269:5269 \
 -p 5290:5290 \
 yunohost/full \
 /sbin/init

You can find more information on these steps on the Docker's documentation:


Post-installation

Find your container's IP address (should looks like 172.17.0.x)

docker inspect --format '{{ .NetworkSettings.IPAddress }}' <CONTAINER_ID>

Then reach https://ip.du.conteneur on your web browser, and proceed to the post-installation step.


Useful commands

Snapshot container's state

docker commit <container_ID> yunohost/full:tag
# E.g.: docker commit 3e85317430db yunohost/full:03052014

Assign an IP to a container

# You will need iptables, and to activate IP forwarding on your system
iptables -t nat -A PREROUTING -d <IP.to.assign> -j DNAT --to-destination <container.IP>
iptables -t nat -A POSTROUTING -s '<container.IP>/32' -o eth0 -j SNAT --to-source <IP.to.assign>
# Be careful on the network interface (here eth0)

Log in a YunoHost running container

# Otherwise, with docker
docker exec -t -i <container_ID> /bin/bash