Answer the question
In order to leave comments, you need to log in
How to transfer data from one docker container to another?
There are 2 docker containers:
1) a self-assembly container (a python script-parser is launched by cron)
2) DB
How to write data from a docker container (1) to a docker container (2)?
Answer the question
In order to leave comments, you need to log in
Combine containers into one virtual network. Of course, you can manually configure everything, but this is not advisable.
Use docker-compose.
docker-compose.yml might look like this:
version: "3.2"
services:
my_db:
image: mysql:8.0.26
restart: always
container_name: mysql8
command: --default-authentication-plugin=mysql_native_password
environment:
MYSQL_ROOT_PASSWORD: superpassword
ports:
working_dir: /var/lib/mysql
volumes:
- "./mysql:/var/lib/mysql:rw"
app:
build: ./app/
command: >
python3 app.py
depends_on:
- my_db
The database from the second container should be available for external connections
if you have mysql, then you can connect to mysql in python, for example, through the root user on localhost:3306 and write the parsed data
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question