K
K
Kutuzov_ska2021-04-12 21:37:21
Docker
Kutuzov_ska, 2021-04-12 21:37:21

How to use Docker?

Hello. I can not understand the essence of Docker.

1. Can I use Docker during development?
- That is, let's not install php locally, but run docker from php?
2. Is it possible to somehow execute commands inside docker-a (by analogy with vagrant, get access to the terminal)?
3. How does Mysql work with docker - Does it keep all data inside a container or refer to local databases?
4. Php + nginx + mysql + composer + symfony + nodejs -> is it possible to run all this with one command (for example, using docker-compose) and get access to the terminal and run npm run from docker, etc.?
5. Do I understand correctly that in order to complete step 4, you need to somehow transfer a link to the project folder to the docker?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Yarkov, 2021-04-12
@yarkov

1. Yes
2. Yes
3. You can use volumes
4. Yes
5. You need to specify in the config which directories and files are used and run docker-compose

I
i1yas, 2021-04-12
@i1yas

1. Yes, I do that a lot, especially for stacks I don't often work with.
2. Here it depends on what you mean.
There are docker run / docker exec / docker-compose run commands, they either create a container and run a command, or run a command on an existing container, for example, bash , or php -a , psql - this way you can get into an interactive environment inside the container.
3. As you wish. By default, all data is stored inside the container and will be lost on the next restart. For data that needs to be saved between restarts, such as a database, there is a volume. In short, you can bind some of the data inside the container either to the file system or to a special docker storage.
4. Yes, for example, you can see how docker-compose.yml php + mysql + nginx are arranged or whatever is closer to you. I recommend just poke, try to run your hello world under docker-compose.
5. Point 4, look at some simple docker-compose.yml so that there is a database and an application in different containers, I think you will have many questions

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question