Docker / CoreOS


Hyperlinks:

Hyperlinks (TransIP specific):

Useful:

  • Where does docker keep stuff (on CoreOS): /var/lib/docker
  • Stuff to auto manage processes inside a containers: supervisord
  • Show all containers (including those that are not running):  docker ps -a
  • Execute shell inside running container: docker exec -i -t 647515407a38 /bin/bash
  • Adding ports to existing containers is impossible, you need to go comtainer->image->container for that

Docker with Ubuntu 16:

  • Install Docker Engine (https://docs.docker.com/engine/installation/linux/ubuntulinux/)

Steps (create working LAMP server and move it to a different machine, hex codes are examples):

Please note we use 222 for ssh as 22 is already used by the CoreOS host.

  • Find images in repository:  docker search centos | grep lamp
  • Create running container from repository image:  docker run -p 80:80 -p 222:22 -i -t nickistre/centos-lamp supervisord
  • See running container: docker ps
  • Convert running container to image: docker commit 77a1a860d288
  • Save image to file: docker save b4c3bffd366ad86a0c5621881937c1254a25fabd17316157c737ccc3b4361d4d > nice_image_name.tar
  • Transport file to different server: scp nice_image_name.tar core@0.0.0.0:/home/core
  • Load image from file: docker load < nice_image_name.tar
  • List images: docker images
  • Start running container from image with shell access (to alter the root password): docker run -p 80:80 -p 222:22 -i -t d44edad54588 /bin/bash
  • Second shell, see running container: docker ps
  • Second shell, convert running container to an image: docker commit 668c9601693a
  • Stop the container (ctrl-c)
  • Start the new image: docker run -p 80:80 -p 222:22 -i -t c66a1c90b8c18ecff41f0101c86bc896dd1ff88de0aa96b952eedd42d966fedd supervisord
  • Second shell, see running container: docker ps
  • Second shell, stop the running container (which will stop it in the first shell):  docker stop 647515407a38
  • From now on use to start: docker start 647515407a38
  • Different machine, access running docker with: ssh root@0.0.0.0 -p 222

Now we have a working persistent container (which can be stopped and started over and over again) with working webserver, mysql and sshd which allows logon.

Makeing it possible to log in into CoreOS on VMWARE:

Step #1: Bang on “e” during boot to get into GRUB and add coreos.autologin:

coreos.autologin

Step #2: sudo passwd core