Docker

Aus Alexander's Wiki

Installation

Paket für Ubuntu

  apt-get install docker lxc

  wget -qO- https://get.docker.com/ | sh
  docker run hello-world

docker-compose

docker-compose macht das Leben ein wenig einfacher.

 curl -L https://github.com/docker/compose/releases/download/1.3.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
 chmod +x /usr/local/bin/docker-compose

Docker Image

 docker run -p 666:80 -i -t ubuntu:12.04 /bin/bash

Der lokale Port 666 zeigt auf den Port 80 im Docker-Image.

Verwaltung

Anzeige der verfügbaren Container

 docker.io ps -a

CONTAINER ID  IMAGE    COMMAND  CREATED       STATUS                  PORTS                NAMES
cc65f386f2d5  nginx:1  nginx    9 months ago  Exited (1) 8 months ago 0.0.0.0:7890->80/tcp dc-nginx

Container starten

 docker.io start cc65f386f2d5

CONTAINER ID  IMAGE    COMMAND  CREATED       STATUS       PORTS                NAMES
cc65f386f2d5  nginx:1  nginx    9 months ago  Up 3 seconds 0.0.0.0:7890->80/tcp dc-nginx

Container stoppen

 docker.io stop cc65f386f2d5

Container löschen

 docker.io rm cc65f386f2d5

Docker Container finden

 docker.io search gitlab

Benutzung

 docker.io attach cc65f386f2d5


Special Gitlab

Gitlab arbeitet mit den Datenbanken:

  • postgress
  • mysql
  • Redis

Einfachste Weg

 wget https://raw.githubusercontent.com/sameersbn/docker-gitlab/master/docker-compose.yml
 docker-compose up

Im Browser http://localhost:10080 aufrufen und mit den folgenden Zugangsdaten einloggen:

  • username: root
  • password: 5iveL!fe

Der manuelle Weg

Ist hier nicht vollständig beschrieben: siehe hier

 docker pull sameersbn/gitlab:latest
 docker pull sameersbn/mysql:latest
 docker run --name=mysql-gitlab -d \
  --env='DB_NAME=gitlabhq_production' \
  --env='DB_USER=gitlab' --env='DB_PASS=password' \
    --volume=/srv/docker/gitlab/mysql:/var/lib/mysql \
    sameersbn/mysql:latest

The above command will create a database named gitlabhq_production and also create a user named gitlab with the password password with full/remote access to the gitlabhq_production database.

 docker run --name=redis-gitlab -d \
  --volume=/srv/docker/gitlab/redis:/var/lib/redis \
  sameersbn/redis:latest
 docker run --name=gitlab -d --link=mysql-gitlab:mysql --link=redis-gitlab:redisio \
  --publish=10022:22 --publish=10080:80 \
  --env='GITLAB_PORT=10080' --env='GITLAB_SSH_PORT=10022' \
  --volume=/srv/docker/gitlab/gitlab:/home/git/data \
  sameersbn/gitlab:latest

Here the image will also automatically fetch the DB_NAME, DB_USER and DB_PASS variables from the mysql container as they are specified in the docker run command for the mysql container. This is made possible using the magic of docker links.