Z
Z
Zmtrk622022-02-01 18:35:26
linux
Zmtrk62, 2022-02-01 18:35:26

How to steer docker-compose in prod?

Hello. How about a lot of questions? It so happened that I climbed from LXC to docker and technically almost everything is clear to me, but the philosophy is not clear in several places. Interested in exactly how you would do it. Suppose we have a web server of medium importance. Services are deployed on it (in docker-compose):

nginx
php-fpm (built from an image with installation of all extentions via Dckerfile)
MySQL

1) And now I want to upgrade the PHP version. To do this, I can build another container in the same yaml file, make a link to it from other services, and then switch backend in the Nginx configs. Norm?
But I can take and build the container in the dockerfile and then tell docker-compose that we are taking a local image?
2) By the way, how do you keep local collected images clean?
3) Is it normal to rebuild services in general? Let me remind you that the site is of medium importance. 1-10 minutes are not critical.
4) General question: Let's say you are an avid Ubuntu user. But suddenly you need to build the same web server as mine, but on a Centos image. There are different library names, extensions for php, package names, etc. And you don't know them. This is not difficult to do on a "live system", but caulking a dockerfile a hundred times with an error reading is nonsense and long. How do you write instructions in a Dockerfile in this scenario?
5) What if I want to temporarily lower one container? Compose will not be offended?

Thanks to all.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Ivanov, 2022-02-01
@DoctorStein

docker-compose is not very good, kubernetes is in vogue now. But if you really want to, then you can:
1. Edit yaml and Dockerfile if necessary. docker-compose build, docker-compose down, docker-compose up -d. If the yaml changes are large, for example, the composition of services changes, then it is worth down first, then editing.
2.3. If possible, images are not built locally. There is a separate development process, images are laid out in a private registry, from where they are taken by the composite.
4. Images are built on what is convenient for the developer. Never had a task to replace the type described. But it happens the other way around - a new OS, old proven dockers are launched on it.
5. docker compse stop servicename

V
Valentine, 2022-02-03
@ProFfeSsoRr

How to steer docker-compose in prod?

No way, this solution is not for selling, but for running on local computers. For selling Kubernetes.
make a link to it from other services and then switch in the Nginx backend configs
if you want to do that, then it's not "medium importance" anymore. If you can afford a simple one, why not just stop the old container and then run the updated one?
But suddenly you need to build the same web server as mine, but on a Centos image. There are different library names, extensions for php, package names, etc.

So, stop, you've got everything mixed up here. You write that you have a server that runs containers. And in containers, you already have a web server inside. So if you have containers - what difference does it make to you what they are inside? Well, in the sense that you take the ones that you like and that you understand, and use it. Why rebuild the container from ubunta to centos when you can go and take it right away with centos? And most importantly - why do this to a person who does not know the names of libraries and all this? If he does not know, he will take what he knows, containers, including for this purpose, were invented - so the developer of ubuntu knows you, uses it, and collects containers based on ubuntu. And then it goes to the prodovy server, which the sysadmins raised on centos, for example, because they think that it suits them better for these tasks.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question