2.7 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 zamentur/yunohost-stable8
You can also build the image manually:
docker build -t zamentur/yunohost-stable8 github.com/YunoHost/Dockerfile
You can check that the container is successfully built with the docker images
command.
Run the container
To start the container, run the next command by replacing DOMAIN by a valid domain e.g.: example.com => yunohost.example.com
docker run -h yunohost.DOMAIN -v $(pwd):/yunohost -d zamentur/yunohost-stable8 /sbin/init
If you want to run the container and forward all the interesting ports to the host:
docker run -d -h yunohost.DOMAIN -v $(pwd):/yunohost \
-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 \
zamentur/yunohost-stable8 \
/sbin/init
You can find more information on these steps on the Docker's documentation:
Post-installation
Go in the container by replacing XXXX by the id obtained when docker run
docker exec -t -i XXXX /bin/bash
Next run postinstall with the dedicated script to docker
postinstall
Useful commands
Find your container's IP address (should looks like 172.17.0.x)
docker inspect --format '{{ .NetworkSettings.IPAddress }}' <CONTAINER_ID>
Snapshot container's state
docker commit <container_ID> zamentur/yunohost-stable8:tag
# E.g.: docker commit 3e85317430db zamentur/yunohost-stable8: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