U
U
Unicom2016-01-27 08:17:23
MySQL
Unicom, 2016-01-27 08:17:23

Docker. How to use it on a web server?

Dear devops and system administrators, I need your help in understanding how Docker works and how to configure it.
For example, my situation is: VDS with Debian, you need to install MySQL(MariaDB), Python/Django, Nginx, Memcached, Sphinx Search inside.
Tasks I want to solve with Docker:

  • resource delimitation of some particularly voracious components (I throw a rock at the MySQL window)
  • the ability to experiment a little with versions and settings of components
  • if something doesn’t suit the hosting, I took my containers and went to another

In recent days, I have read a bunch of manuals and explanations of why, and how docker works, a bunch of examples on application development, but here is my use case in its purest form, I did not find a solution to my problems - only hints, half-hints and mean lines, yes, like this you can do it, but nothing detailed, comprehensive for understanding, and even more so, no instructions of such a plan: take it from here - put it there, then run this command, because ...
The main questions that I still have:
1) containers states, but I still need to store and create data, how to create, record and store changes?
2) how to automatically start containers with changes if some drunken moron cut the wire from the DC with a shovel and everything went out? That is, how to turn stateless containers into stateful in simple ways. T / e server falls, rises and everything works from the place where it fell.
3) What is the best way to containerize my server binding?
4) How to choose the necessary application containers on Dockerhub?
5) How and where to store data (for example, Django projects) so as not to lose them, but at the same time it is convenient to migrate to another host in case something happens
6) Due to a misunderstanding of how everything works: how (and is it even possible) to prevent leaking any sensitive data to dockerhub along with some of my container image?

Answer the question

In order to leave comments, you need to log in

7 answer(s)
S
Sergey, 2016-01-28
@pacahon

You read a bunch of manuals, but missed the most important thing - the official documentation. How so? It just says how to do it and why. The questions have already been answered, but I'll go through again, since I spent so much time reading the answers:>
1) https://docs.docker.com/engine/userguide/dockervolumes/
2) https://docs.docker.com/engine /articles/host_integ...
3) The answer is simple - whatever you want. As only you know better, sounds trite, but it's true. If you want to stuff everything into one container, that's up to you. Although they recommend 1 component per 1 container. This has its own logic - you only want to update mysql - you update this container and don't think if your uwsgi or nginx is broken or something else.
4) Write your first Dockerfile, it will become much clearer how to choose. In the meantime, trust only official images.
5) git? This question is a consequence of misunderstanding of the question 1)
6) Already answered. The simplest, if you don't understand, don't use dockerhub at all. Or start understanding. :) Or pay for private repositories so you don't have to think about it.

N
Nazar Mokrinsky, 2016-01-28
@nazarpc

1) data-only containers
2) solve the problem of raising the server itself with Docker running, set the policy to always restart in containers - they will start together with Docker itself
3) ideally, by container per process or logical part, for example, MariaDB is one, Python server this is the second and so on
4) carefully study the internals, except for the official ones, choose only those that have automatic builds with an open Dockerfile and are kept up to date, sometimes you have to make your own
5) the answer is the same as 1) + backup / restore from volumes
6) do not embed sensitive data in images and will not get
As a good example, you can see my development (although it is focused on PHP, but the essence is the same, see how it works): https://github.com/nazar-pc/docker-webserver

E
Ergil Osin, 2016-01-27
@Ernillew

> docker. How to use it on a web server?
No way. Docker is a toy technology not intended for real-world use. By installing docker, you are clearly telling yourself "I don't care about security updates, I don't need them."
If you need containerization then there is lxc.

S
Sergey Novikov, 2016-02-07
@novikovSU

About the level of management of the entire infrastructure. There is a lot of talk about Google Kubernetes these days. However, I personally liked the not so hyped, but very fancy Rancher more. I think it suits you well. He will:
a. Connect machines from different cloud providers to one web(!)-console.
b. Manage most of the parameters of both containers directly and larger bundles.
with. Manage volumes for storing persistent data. The problem of transferring data between hosts can be solved there by raising the GlusterFS cluster in 3 clicks, for example. It also has its own development for the sink - Convoy.
d. Control the functioning of services and hosts by automatically starting containers on other hosts.
e. Raise between hosts (let me remind you that they can be located in different DCs from different providers) your private network, where all hosts and all services can "see" each other.
f. Balance load across multiple containers on different machines.
There is no magic there. Everything can be configured and so. However, as a starter solution that will hide a lot of configuration complexities, it should work well.

D
Dimonchik, 2016-01-27
@dimonchik2013

questions 3,4,6 - for the psychic forum
on the first two: one and two , and there are still links from there,
we use Muskul outside containers,
and, frankly, I don’t know when to use it inside (unless what if you are a hoster): if the project is small - it does not eat the database much, and if the project is such that the database is gigabyte - skipping through the docker pad is not taking care of data safety.
but nginx and wsgi (with Jungs and Flasks) feel great in containers

N
Nikolai Turnaviotov, 2016-01-27
@foxmuldercp

I'll try on the fingers
of the database - in normal containers like lxc / openvz or in a separate vps. purely because backups and replication are there in normal mode with normal access, plus, again, the ip address is static, which is not in the docker and is unlikely to be.
docker containers are a repeatable virtual machine of the name of a single process. That is, you clearly say in the dockerfile what, why to execute and what exactly to run in the background, i.e. in the foreground, the service apache2 start option does not work, the container will stop after the application leaves the background, also read about the docker pid 1 problem and why this is everything is launched in a binding from the same bash.
Docker is very strongly tied to his hub and git, so that "git pull & start app with one button" on some internal IP from the gray network.

D
devel787, 2016-02-04
@devel787

dou.ua/lenta/articles/docker
+
dou.ua/lenta/articles/vagrant

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question