作者:老娘叫凌凌_523 | 来源:互联网 | 2022-12-06 19:29
情况:
我有一个selenium app
(在python中)将自己连接到网站上的帐户,以便下载几个CSV文件.要运行它,我使用docker
(和docker-compose
)这是我的docker-compose.yml
文件
version: '3'
services:
selenium:
build:
context: .
dockerfile: compose/selenium/Dockerfile
ports:
- "4444:4444"
volumes:
- /dev/shm:/dev/shm
- download-folder:/home/seluser/downloads
enma:
build:
context: .
dockerfile: compose/enma_daio/Dockerfile
depends_on:
- selenium
volumes:
- download-folder:/data/selenium-downloads
env_file:
- .env
restart: always
volumes:
download-folder:
我selenium's Dockerfile
只是一种downloads
使用官方selenium docker图像创建文件夹的方法
FROM selenium/standalone-chrome
RUN mkdir -p /home/seluser/downloads
要运行我的任务,我使用:
docker-compose run -d enma daio arg0 arg1 arg2
顺便说一下,我也使用了entrypoint.sh:
#!/bin/bash
set -e
cd /app
# Selenium takes a bit of time before being up so we wait until we can reach it
function selenium_ready(){
curl selenium:4444 &>/dev/null
}
until selenium_ready; do
>&2 echo "Waiting for selenium..."
sleep 1
done
if [ "$1" = 'daio' ]; then
shift
exec python enma.py $@
fi
exec "$@"
问题:
当我同时运行多个实例(在同一网站上的不同帐户上)时,他们共享same selenium container
,所以same volume
.所有下载的文件混合在一起,我不知道哪个文件来自哪个run
.
我想做什么:
我selenium container
每次运行新任务时都想创建另一个.或者找到使用不同卷的其他方法.