Z
Z
Zmtrk622021-05-27 09:13:35
linux
Zmtrk62, 2021-05-27 09:13:35

The order of your actions when creating services on Docker?

Good afternoon. I would like to receive information about your experience in working with Docker services.
Example:
I am making a Docker-compose file, I describe a primitive web server (Nginx, PHP-FPM, MySQL)
in it. Accordingly, I pull all the images from Dockerhub.
1) But I have a desire to get ALL configs of all services to the local machine using volume.
How should I get those configs that are already in the authors' image? After all, if I describe volume in a file, then my local directory will immediately be thrown into the container already with my conf files.

2) I'm used to building systems on LXC, but docker has more advantages in my situation. Tell me, is Docker-compose in production is the norm? How should I install, for example, another module for PHP?

3) I know about Kubernates and the like, but for a project that is inherently static, it is redundant.

Thank you!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
X
XEHKOK, 2021-05-27
@Zmtrk62

I usually pull the software configs for new projects from the images.
1) You can either just start building and run the software, or through the Dockerfile or even docker-compose up -d --build, this is already a personal matter as religion allows)
I usually pull it like this:
PHP:
docker cp container or service name: / usr /local/etc/php-fpm.conf /var/www/projects/mynewproject/docker/php/php-fpm.conf
docker cp container or service name: /usr/local/etc/php-fpm.d/www. conf /var/www/projects/mynewproject/docker/php/www.conf
docker cp container or service name:/usr/local/etc/php/php.ini-development /var/www/projects/mynewproject/docker/php /php.ini
The left paths are the placement in the config container, the right paths are where to copy to the host system.
After receiving the initial configs, I write them to the PHP service Dockerfile:
COPY /var/www/projects/mynewproject/docker/php/php.ini /usr/local/etc/php/php.ini
COPY /var/www/projects/mynewproject/ docker/php/php-fpm.conf /usr/local/etc/php-fpm.conf
COPY /var/www/projects/mynewproject/docker/php/www.conf /usr/local/etc/php-fpm.d /www.conf
True, I don’t do this through a volume, of course, but this is again a matter of religion)
Actually, you can pull out configs for Nginx in the same way:
docker cp container or service name: /etc/nginx/nginx.conf /var/www/projects /mynewproject/docker/nginx/nginx.conf
docker cp container or service name: /etc/nginx/conf.d/default.conf /var/www/projects/mynewproject/docker/nginx/default.conf
For the new Nginx, there even seems to be a template config file: /etc/nginx/templates/default.conf.template, which can be taken as the basis for nginx virtual hosts.
Well, for the database and other software, I think it will not be difficult to dig into the images or google)
2) If I understood correctly about the ext-php modules:
There are several options for the modules that are included in the base php assembly, you can install it like this:
RUN docker-php-ext- install -j$(nproc) soap
Those that need to be installed and forced to be enabled:
RUN docker-php-ext-install -j$(nproc) opcache && docker-php-ext-enable opcache Others
that need to be configured like zip:
RUN apt -get update && apt-get install -y --no-install-recommends libzip-dev zip
RUN docker-php-ext-configure zip && docker-php-ext-install -j$(nproc) zip You
can also install extensions from PECL using pthreads as an example:
RUN pecl install pthreads && docker-php-ext-enable pthreads
In general you can dockenize a php project, the main thing is to know the basics of docker and the specifics of the software that you need to raise in this very docker.

D
Dmitry Shitskov, 2021-05-27
@Zarom

  1. I don’t know why you need this, but I see only this way - run the container and use docker cpit to copy the necessary configs to your host.
  2. Composite without using build is quite possible and productive. Any modules, like your code, are updated by the standard method for Docker - building a new container with updated modules, delivering the entire container for sale

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question