I have created below docker file and the intention is to run it in docker-compose.
FROM python:3.7.5-slim
WORKDIR /usr/src/app
RUN python -m pip install boto3
COPY test_cf_create_or_update.py .
ENTRYPOINT ["python3"]
CMD [@]
Now after the build, when I run it I have expected outcome.
docker build -t test .
docker run -it --rm test test_cf_create_or_update.py
However, If I do want to recreate same via docker-compose, it's saying
setup-application_1 | python3: can't open file '/usr/src/app/test_cf_create_or_update.py': [Errno 2] No such file or directory
localstack_setup-application_1 exited with code 2
Sample of docker-compose looks like below:
setup-application:
build: .
volumes:
- /tmp/localstack/application:/usr/src/app
environment:
- AWS_ACCESS_KEY_ID=dummyaccess
- AWS_SECRET_ACCESS_KEY=dummysecret
- AWS_DEFAULT_REGION=eu-west-1
entrypoint: python3
command: /usr/src/app/test_cf_create_or_update.py
networks:
- my_localstack_network
depends_on:
- localstack
Can anyone assist me in where I'm doing wrong?
Two solutions:
Remove volume
from docker-compose
and
FROM python:3.7.5-slim
COPY test_cf_create_or_update.py .
WORKDIR /usr/src/app
RUN python -m pip install boto3
ENTRYPOINT ["python3"]
CMD [@]
Or keep volume
in docker-compose
and
FROM python:3.7.5-slim
WORKDIR /usr/src/app
RUN python -m pip install boto3
ENTRYPOINT ["python3"]
CMD [@]
Make sure your test_cf_create_or_update.py
is in /tmp/localstack/application
folder.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.