doc/docker.md

110 lines
2.4 KiB
Markdown
Raw Normal View History

2014-06-05 13:56:19 +02:00
# 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)**.*
<img src="https://yunohost.org/images/docker.png" width=250>
---
## Install Docker
2015-04-12 23:12:03 +02:00
**Pre-requisite**: a x86 computer under Ubuntu 14.04 (or above), or ArchLinux.
2014-06-05 13:56:19 +02:00
2015-04-12 23:05:00 +02:00
On Ubuntu :
2014-06-05 13:56:19 +02:00
```bash
curl -s https://get.docker.io/ubuntu/ | sudo sh
```
2015-04-12 23:05:00 +02:00
On ArchLinux :
2014-06-05 13:56:19 +02:00
```bash
sudo pacman -Sy docker
```
2015-04-12 23:12:03 +02:00
**Note:** you may have to start Docker's daemon manually (as root: `service docker start`, `systemctl start docker` or simply `docker -d`)
2014-06-05 13:56:19 +02:00
---
## Build the YunoHost container
2015-04-12 23:05:00 +02:00
The following command will fetch the latest YunoHost built image:
```bash
docker pull yunohost/full
```
You can also build the image manually:
2014-06-05 13:56:19 +02:00
```bash
2015-04-12 23:05:00 +02:00
docker build -t yunohost/full github.com/YunoHost/Dockerfile
2014-06-05 13:56:19 +02:00
```
You can check that the container is successfully built with the `docker images` command.
---
## Run the container
```bash
2015-04-12 23:05:00 +02:00
docker run -d yunohost/full /sbin/init
2014-06-05 13:56:19 +02:00
```
2015-04-12 23:05:00 +02:00
If you want to run the container and forward all the interesting ports to the host:
2014-06-05 13:56:19 +02:00
2015-04-12 23:05:00 +02:00
```bash
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
```
2014-06-05 13:56:19 +02:00
2015-04-12 23:05:00 +02:00
You can find more information on these steps on the Docker's documentation:
2015-02-04 11:32:19 +01:00
* http://docs.docker.com/reference/commandline/cli/#run
* http://docs.docker.com/userguide/dockerlinks/
2014-06-05 13:56:19 +02:00
---
2015-04-12 23:05:00 +02:00
## Post-installation
Find your container's IP address (should looks like 172.17.0.x)
2014-06-05 13:56:19 +02:00
2015-04-12 23:05:00 +02:00
```bash
docker inspect --format '{{ .NetworkSettings.IPAddress }}' <CONTAINER_ID>
```
Then reach https://ip.du.conteneur on your web browser, and proceed to the [post-installation](/postinstall) step.
---
## Useful commands
2014-06-05 13:56:19 +02:00
2015-04-12 23:05:00 +02:00
Snapshot container's state
2014-06-05 13:56:19 +02:00
```bash
2015-04-12 23:05:00 +02:00
docker commit <container_ID> yunohost/full:tag
# E.g.: docker commit 3e85317430db yunohost/full:03052014
2014-06-05 13:56:19 +02:00
```
2015-04-12 23:05:00 +02:00
Assign an IP to a container
2014-06-05 13:56:19 +02:00
```bash
# 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)
```
2015-04-12 23:05:00 +02:00
Log in a YunoHost running container
2014-06-05 13:56:19 +02:00
```bash
2015-02-04 11:32:19 +01:00
# Otherwise, with docker
2015-04-12 23:05:00 +02:00
docker exec -t -i <container_ID> /bin/bash
2014-06-05 13:56:19 +02:00
```