Docker

From EWIKI
Jump to navigation Jump to search

Docker installation on Ubuntu is quiet easy:

Buuut: don't use the package manager, cause you'll get really old stuff

Install directly from docker:

Enable remote config

Prepare linux (Ubuntu only)

You need to turns off dnsmasq usage in NetworkManager configuration:

sed 's@dns=dnsmasq@#dns=dnsmasq@' -i /etc/NetworkManager/NetworkManager.conf 
sudo service network-manager restart 

Check:

cat /etc/resolv.conf 
nm-tool

Configure docker remote control

mh@AspireOne:~$ vi /etc/default/docker

add

DOCKER_OPTS="-H tcp://127.0.0.1:4243 -H unix:///var/run/docker.sock"

(on CentOS/RHEL it is other_args=)

mh@AspireOne:~$ sudo restart docker
mh@AspireOne:~$ netstat -ant  |grep 4243
tcp        0      0 127.0.0.1:4243          0.0.0.0:*               LISTEN

Install Shipyard

Source: https://github.com/shipyard

Shipyard Controller

mh@AspireOne:~$ docker run -it -d --name shipyard-rethinkdb-data --entrypoint /bin/bash shipyard/rethinkdb -l
...
mh@AspireOne:~$ docker run -it -P -d --name shipyard-rethinkdb --volumes-from shipyard-rethinkdb-data shipyard/rethinkdb
...
mh@AspireOne:~$ docker run -it -p 8080:8080 -d --name shipyard --link shipyard-rethinkdb:rethinkdb shipyard/shipyard
...
docker ps
... 

This is a good time to think of iptables and restrict some ports.

Start Shipyard Controller as Service

To start shipyard after booting

Create /etc/init/shipyard-controller.conf

description "Shipyard Controller and Web UI"
 
start on runlevel [2345]
stop on runlevel [!2345]
 
respawn
 
exec /usr/bin/docker start -a shipyard
 
pre-stop exec /usr/bin/docker stop -t 2 shipyard

Create /etc/init/shipyard-controller.conf

description "Shipyard Controller Rethink DB"
 
start on starting shipyard
stop on stopping shipyard
 
respawn
 
exec /usr/bin/docker start -a shipyard-rethinkdb
 
pre-stop exec /usr/bin/docker stop -t 2 shipyard-rethinkdb

Web UI

Open http://localhost:8080 in browser. Initial credentials are admin/shipyard.

CLI

Docu: http://shipyard-project.com/docs/usage/cli/

Run CLI

docker run -ti --rm shipyard/shipyard-cli
...
shipyard cli> shipyard login
URL: http://192.168.2.113:8080
Username: admin
Password: shipyard
shipyard cli> shipyard engines
ID					Name	Cpus	Memory	Host				Labels	Health	Response Time (ms)	Docker Version
bc7870c2-a872-4e5f-bae1-5180306da836	aspire	1.00	1024.00	http://192.168.2.113:4243	master	up	0.7			

The next thing you should do now:

  • change admin password
  • add users
shipyard change-password
...
shipyard add-account -u mh -p somthingverysecret -r admin

Shipyard Engines (no hardening!)

That are the managed docker hosts.

mh@AspireOne:~$ sudo vi /etc/default/docker

Add

DOCKER_OPTS="-H tcp://0.0.0.0:4243 -H unix:///var/run/docker.sock"

and restart the docker service

mh@AspireOne:~$ sudo restart docker

Remark: shipyard-agents are not longer supported by shipyard, but you will find legacy docu on the net.

Create Apache/PHP container

mkdir dockerapache
cd dockerapache

Cheats

Run a command or image in a new container:

docker run <command/image>

Show all containers, also stopped ones:

docker ps -a

Start/Stop a container

docker start <name or id>
docker stop <name or id>

Build a new image from a dockerfile:

docker build -t <imagename> .

Show logs from a container:

docker log <name or id>

Connect to a (running) container

docker attach <name or id>

Used Versions

Linux:

mh@AspireOne:~$ uname -a
Linux AspireOne 3.16.0-37-generic #51-Ubuntu SMP Tue May 5 13:45:59 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
 
mh@AspireOne:~$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 14.10
Release:	14.10
Codename:	utopic

Docker

mh@AspireOne:~$ docker version
Client version: 1.6.2
Client API version: 1.18
Go version (client): go1.4.2
Git commit (client): 7c8fca2
OS/Arch (client): linux/amd64
Server version: 1.6.2
Server API version: 1.18
Go version (server): go1.4.2
Git commit (server): 7c8fca2
OS/Arch (server): linux/amd64

Shipyard

shipyard cli> shipyard info
Controller Version: 2.0.10