How to effectively use Docker + Docker-compose in the development?

With Docker tight never not worked and now there is a need, because in the future the app will need to deploy on a remote server.
Distribute a small docker-compose based on znanih with the read information
docker-compose.yaml
version: '3'

services:
parser:
 build: ./parser
 restart: always
 container_name: JaScrapy01
depends_on:
 - postgres
 - redis
volumes:
 - ./parser:/JaScrapy
networks:
 - net
env_file:
 - .env
postgres:
 image: postgres:11.3-alpine
 restart: always
 container_name: postgres01
networks:
 - net
volumes:
 - ./postgres/data/var/lib/postgresql/data
env_file:
 - .env
redis:
 image: redis:5.0.5-alpine
 restart: always
 container_name: redis01
networks:
 - net
volumes:
 - ./redis/data:/data
env_file:
 - .env

networks:
 net:


But it is very uncomfortable! Yes, climb the containers with postgresql and redis, it is comfortable, but cannot connect from outside (due to the use of networks, and how to access the network - guess yourself), for example to view the information through the GUI. If you make any changes in main application -- one can only hope that they're going to appear in the container. Can five times to remove the container with the app, then ten times to remove image -- any changes will not get anywhere. To use the virtual environment on the local machine by running the application through it is impossible, because the network database somewhere local. Pycharm can use the interpreter running inside the container - but it connectios when it one time and then are only given a java error and PyCharm'.

Actually, the question is how to effectively and comfortably work with this?
March 23rd 20 at 18:52
3 answers
March 23rd 20 at 18:54
Solution
but cannot connect from outside (due to the use of networks, and how to access the network
guess you need to)

And using directives ports - don't need prokalyvayutsya ports in the containers outside?

If you make any changes in main application
one can only hope that they're going to appear in the container

If you make changes to the project which primapin through volume container immediately sees.
Can your app to see what local files have changed and to apply them is another question.
But even if he can not - there is no problem to prestarting the desired container after making any changes.

Can five times to remove the container with the app, then ten times to remove the image
any changes will not get anywhere.

I do not know you are built - but will bring about examples of projects in python.
In Python, a folder is created with a virtual environment where to install all the required libraries to work. This folder will mapitse together with the container. This uses the python container from a standard image on all the projects and virtual environments - from primplanul directory. There is no need to install anything extra into containers. So what you're trying to do with images - is unclear...

To use the virtual environment on the local machine by running the application through it is impossible
because the network database somewhere local.

Well here is to decide - using Docker for this, or a virtual environment on your machine.
If you want to simultaneously use both - prokidyvaya ports.

If you make changes to the project which primapin through volume container immediately sees.
Can your app to see what local files have changed and to apply them is another question.

Not true. Have tadalail application to at least some changes to look - you need to spend 10 minutes to first remove all the containers with your hands, then remove all the images by hand, then reassembled. - cielo.Sauer commented on March 23rd 20 at 18:57
@cielo.Sauer,
I don't know - what am I doing wrong that I have seen everything?

$ cat docker-compose.yml
version: '3.1'
services:

test:
 image: python:3
 container_name: test-p3
volumes:
 - ./somedir:/opt/my_project
 entrypoint: tail-f /dev/null


$ mkdir somedir
$ docker-compose up-d
Creating network "00001_default" with the default driver
Creating test-p3 ... done
$ ls ./somedir/
$ docker exec-ti test-p3 ls /opt/my_project/
$ touch ./somedir/1.txt
$ docker exec-ti test-p3 ls /opt/my_project/
1.txt
$ docker exec-ti test-p3 cat /opt/my_project/1.txt
$
$ echo "test test" > ./somedir/1.txt
$ docker exec-ti test-p3 cat /opt/my_project/1.txt
test test


You question did not indicate their system. Probably you have Docker installed using any crutches, because of which all your inconvenience. - alfonzo.Bartel commented on March 23rd 20 at 19:00
> Not true. Have tadalail application to at least some changes to look - you need to spend 10 minutes to first remove all the containers with your hands, then remove all the images by hand, then reassembled.

You seriously? What you need to spend ten minutes to make some changes to see does the words of Vladimir "wrong". You with such an attitude will discourage all desire to answer you. Looks like this:
This hammer is terribly uncomfortable thing, I can't do anything to them to score. How do you use it?
- Take him by the arm and hit on the nail head, which want to hammer a nail is driven is wonderful.
- But not true! 10 minutes I hammered a nail into something and he's all bent!

Well as though Yes, if you score in the metal - it is to be expected, for example. This does not mean that the hammer used for the purpose of "not working". Write more business. What are you trying to achieve and what exactly you can do about it. No need to evaluate the words of more experienced people - you can't do it adequately. - jarred_Champl commented on March 23rd 20 at 19:03
March 23rd 20 at 18:56
Solution
You have got the typical problem.
Forget about docker-compose for the next month and a half. IMHO, about it is generally impossible to tell and show those who are just starting to deal with Docker. It hurts.
Use docker cli. You quickly take in and understand everything. Yes, you will have to run 1 container at a time or write a short script. But you develop this flexibility that gives the docker cli and the experience you gain will be a great help.
March 23rd 20 at 18:58
Solution
Somehow you don't really know.
Throw "networks:". In your case it is not needed.
Add "ports", where you want to use to use the service. For example in postgresql container.
Here is the file ".env" throw it, too, if you don't have a lot of variables enter them so.

To do container not until the end of the running program slika no. It is possible to raise the database and all sorts of other services, and the program itself to run locally and let it be drawn to the fact that krutza in containers. When will be ready the first version, it can already be wrapped in a container.

Find more questions by tags DockerPyCharmPython