Docker: Difference between revisions

From Wildsong
Jump to navigationJump to search
Brian Wilson (talk | contribs)
Brian Wilson (talk | contribs)
mNo edit summary
Line 4: Line 4:
After looking at docker.com, go to https://github.com/docker/docker and look for installation instructions there.
After looking at docker.com, go to https://github.com/docker/docker and look for installation instructions there.


I am following their instructions to install on two Debian systems, one co-located and one at home.
I am following their instructions to install on a [[Synology]] NAS and on two Debian systems, one co-located and one at home.


I want to set up containers for [[Geonode]] and [[Geoserver]].
I want to try out Solr/Lucene (and Tomcat) but don't want to go through the whole installation thing, I just want it all running right now. So I am going to cut to the chase and load a pre-built docker.


I know how fiddly Geoserver can be (it runs in Tomcat) and so I want to isolate it from the Debian host it will run on.
Running Java servlets can be a pain because of the requirement to set up Tomcat, and often the apps require a specific version of Tomcat and Java. So running the whole thing in Docker should be easier.
 
I left my notes on ownCloud down below, I wanted to put it on the Synology NAS. It's not a priority right now since I have switched to using Synology Cloud Station.
 
I also want to set up containers for [[Geonode]] and [[Geoserver]]. I know how fiddly Geoserver can be (it runs in Tomcat, too) and so I want to isolate it from the Debian host it will run on.


I already have PostgreSQL 9.5 running directly on the host, but my only intended use is as a backend for PostGIS/Geoserver,
I already have PostgreSQL 9.5 running directly on the host, but my only intended use is as a backend for PostGIS/Geoserver,
so I will probably follow along with the instructions here and containerize it too.
so I will probably follow along with the instructions here and containerize it too.


So in preparation for using Docker. I removed PostgreSQL and Tomcat from my host server.
So in preparation for using Docker. I removed PostgreSQL and Tomcat from my host server. Take that!


For starters with Geoserver, see
[http://kartoza.com/en/blog/orchestrating-geoserver-with-docker-and-fig/ Orchestrating Geoserver with Docker and Fig]
[http://kartoza.com/en/blog/orchestrating-geoserver-with-docker-and-fig/ Orchestrating Geoserver with Docker and Fig]
I have no idea what Fig is, yet. Sounds tasty.


I have no idea what Fig is, yet.
== Development on Mac ==


== Development on Mac ==
Install [https://download.docker.com/mac/stable/Docker.dmg Docker for Mac] (unless your Mac is too old, boo hoo like [[Stellar]]) or Kitematic. Kitematic installs VirtualBox. Docker for Mac is lighter weight. If you already use Vagrant (for MySQL for example) then you already need VirtualBox so Kitematic is fine.


Set up a Vagrant machine to run an instance of MySQL. Make sure it has port 3306 open and set a root password.
Asking to download Kitematic takes me to the [https://github.com/docker/toolbox/releases/tag/v1.12.5 Docker Toolbox] download page.
Install Docker for Mac and Kitematic.


== Docker Hub ==
== Docker Hub ==
Line 59: Line 64:


== Owncloud ==
== Owncloud ==
Set up a Vagrant machine to run an instance of MySQL. Make sure it has port 3306 open and set a root password.


I want to run Owncloud, so I need these components
I want to run Owncloud, so I need these components
Line 102: Line 109:
and learn about all the missing PHP modules, which includes
and learn about all the missing PHP modules, which includes


zip
* zip
Dom
* Dom
XMLReader
* XMLReader
libxml
* libxml
ctype
* ctype
zlib
* zlib
 


=== Redis ===
=== Redis ===


Used by owncloud (via PHP) and by nginx.
Used by owncloud (via PHP) and by nginx.
It needs some file space.
It needs some file space. Make sure you get a new enough Redis to work with owncloud.


docker run --name redis-owncloud -d redis redis-server --appendonly yes
docker run --name redis-owncloud -d redis redis-server --appendonly yes

Revision as of 05:40, 23 December 2016

Docker is a container platform.

It's open source but if you go to the site, you won't be able to tell, you can just find out about pricing there. After looking at docker.com, go to https://github.com/docker/docker and look for installation instructions there.

I am following their instructions to install on a Synology NAS and on two Debian systems, one co-located and one at home.

I want to try out Solr/Lucene (and Tomcat) but don't want to go through the whole installation thing, I just want it all running right now. So I am going to cut to the chase and load a pre-built docker.

Running Java servlets can be a pain because of the requirement to set up Tomcat, and often the apps require a specific version of Tomcat and Java. So running the whole thing in Docker should be easier.

I left my notes on ownCloud down below, I wanted to put it on the Synology NAS. It's not a priority right now since I have switched to using Synology Cloud Station.

I also want to set up containers for Geonode and Geoserver. I know how fiddly Geoserver can be (it runs in Tomcat, too) and so I want to isolate it from the Debian host it will run on.

I already have PostgreSQL 9.5 running directly on the host, but my only intended use is as a backend for PostGIS/Geoserver, so I will probably follow along with the instructions here and containerize it too.

So in preparation for using Docker. I removed PostgreSQL and Tomcat from my host server. Take that!

For starters with Geoserver, see Orchestrating Geoserver with Docker and Fig I have no idea what Fig is, yet. Sounds tasty.

Development on Mac

Install Docker for Mac (unless your Mac is too old, boo hoo like Stellar) or Kitematic. Kitematic installs VirtualBox. Docker for Mac is lighter weight. If you already use Vagrant (for MySQL for example) then you already need VirtualBox so Kitematic is fine.

Asking to download Kitematic takes me to the Docker Toolbox download page.

Docker Hub

apt-get install docker-engine

Metadata

Get an id:

docker ps

Look at a container in detail

docker inspect id

See also /var/lib/docker/containers/id

Docker networking

Check ifconfig docker0 to see what the bridge address is on your docker server then as needed create a route on your router so that traffic can flow from your local computers into the docker instances running on the docker server.

If you have more than one docker server you have to make sure they don't both pick the same network ip range. If routes are already set up in the router docker should be able to find an unused subnet.

docker pull nginx

cd static-html-directory cat <<EOF > nginx.docker FROM nginx COPY static-html-directory /usr/share/nginx/html EOF

Place this file in the same directory as your directory of content ("static-html-directory"), run ., then start your container:

docker run --name some-nginx -d some-content-nginx

Owncloud

Set up a Vagrant machine to run an instance of MySQL. Make sure it has port 3306 open and set a root password.

I want to run Owncloud, so I need these components

  1. Nginx
  2. php 7 vinaocruz/php7-fpm-mysql
  3. Redis redis
  4. Owncloud (Owncloud is just some files so it does not need a separate docker container)
  5. MySQL (which runs on the host not in Docker)

Nginx + PHP

I need to pick an approach and then have to pick some images. I could use the generic nginx image and a separate php image but then I'd have to get them to work together. Instead I am trying to find a good combined nginx + php image. Lots of images on Docker Hub have no useful information, making them relatively useless. Look for ones with stars, if other people like them they are probably better. maxexcloo/nginx-php seems to have a pretty descriptive doc page.

Set up a web server, copying the files I want to serve into it and mapping it to port 80 on the host. This works as long as there is not already a web server on the host.

Basic server:

docker run --name="debian" -it maxexcloo/debian bash
docker run --name="nginx" -d -p 80:80 maxexcloo/nginx-php
mkdir owncloud-server
cd owncloud-server
unzip Downloads/owncloud*.zip
cat >Dockerfile <<EOF2 
FROM virtualgarden/nginx-php7
COPY owncloud /app
EOF2

Building this image will copy all the owncloud files into the container. You have to preconfigure the owncloud configuration before doing this step.

docker build --label owncloud_server --tag owncloud_server .

Starting an instance will already have all the files. docker run -d --name owncloud -p 80:80 443:443 owncloud_server

Then open up http://localhost/ and learn about all the missing PHP modules, which includes

  • zip
  • Dom
  • XMLReader
  • libxml
  • ctype
  • zlib

Redis

Used by owncloud (via PHP) and by nginx. It needs some file space. Make sure you get a new enough Redis to work with owncloud.

docker run --name redis-owncloud -d redis redis-server --appendonly yes

I need to learn more about persistent data.

Linking it all together

Server: MySQL Create an owncloud database, with a user owncloud allowed full access to the database. Make sure that the Nginx server can connect to it through the private LAN. (I run MySQL on the Docker host.)

Source: Redis Start the Redis docker as a source

Source: PHP7 Start the FPM PHP7 docker as a source

Receiver: Nginx Start the Nginx docker as a receiver for the services from Redis and PHP7. Add environment settings to tell it how to find MySQL.