1

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

xpt
  • 20,363
  • 37
  • 127
  • 216
Flo
  • 2,699
  • 4
  • 24
  • 46
  • moving data will always be a problem, docker will not help it. `docker` will help to setup your environment more quickly once you can set it all in your machine and when it became stable you can just start the same containers in the cloud, all the configuration you have for nginx, mysql e wp could be embedded in the images, so when you move it again or create a new instance of the service will be "easy" as a `docker run`. But the database data and other content that is created after the setup be completed will need to be exported and imported in the new server. – Lucas dos Santos Abreu Feb 12 '17 at 12:19
  • this question may help you: http://stackoverflow.com/questions/16047306/how-is-docker-different-from-a-normal-virtual-machine – Lucas dos Santos Abreu Feb 12 '17 at 12:21
  • The way you phrased your requirements, it sounds like you want a *Virtual Machine* like Oracle Virtual Box or VM Ware, and others. The link provided by @lucas is a good read. A pitfall to watch out for: your web host options for a VM are going to be fewer, and likely more expen$ive. – Paulb Feb 12 '17 at 12:28

1 Answers1

1

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.

NZD
  • 1,780
  • 2
  • 20
  • 29