Flo
Flo

Reputation: 3067

Understanding Docker for providing services like web, mysql or similar

I have several questions regarding Docker.

First my project: I have a blog on a shared host and want to move it to the cloud to have all the server sides in my hands and to have the possibility to scale my server on my needs.

My first intend was to setup a nice ubuntu 14 lts as a server with nginx, php 7 and mysql. But I think it's not that easy to transfer such a server to another cloud i.e. from gce to aws. I then thought about using docker, as a friend told me how easy it is to setup containers and how easy it is to move them from one server to another.

I then read a lot about docker but stumbled upon a few things I wondered about.

In my understanding docker runs just services like php, mysql or similar, but doesn't hold data, right? Where would I store all the data like database, nginx.conf, php.ini and all the Files I want to serve with nginx (ie. /var/www/)? Are they stored on the host system? If yes, it would not be easier to move a docker setup then move a whole server, no?

Do I really have an advantage of using Docker to serve a Wordpress Blog or another Website using MySQL and so on?

Thanks in advance

Upvotes: 1

Views: 95

Answers (1)

NZD
NZD

Reputation: 1970

Your data is either stored on the host machine or you data is attached to the docker containers remotely (using a network-attached block device).

When you store your data on the host machine, you have a number of options.

  1. The data can be 'inside' one of your containers (e.g. your mysql databases live inside your mysql container).

  2. You can mount one or more directories from your host machine inside your containers. So then the data lives on your host.

  3. You can create Docker volumes or Docker volume containers that are used to store your data. These volumes or volume containers are mounted inside the container with your application. The data then lives in directories managed by Docker.

For details of these options, see dockervolumes

  1. The last option is that you mount remote storage to your docker containers. Flocker is one of the options you have for this.

At my work I've set up a host (i.e. server) that runs a number of services in docker containers. The data for each of these services 'lives' in a Docker data volume container.

This way, the data and the services are completely separated. That allows me to start, stop, upgrade and delete the containers that are running my services without affecting the data.

I have also made separate Docker containers that are started by cron and these back up the data from the data volume containers.

For mysql, the backup container connects to the mysql container and executes mysqldump remotely.

I can also run the (same) containers that are running my services on my development machine, using the data that I backed up from the production server.

This is useful, for instance, to test upgrading mysql from 5.6 to 5.7.

Upvotes: 1

Related Questions