Z
Z
zlodiak2019-06-17 15:28:58
Python
zlodiak, 2019-06-17 15:28:58

How to run a bottle app as a docker container?

I wrote the simplest application on the bottle framework and it works without problems on the localhost. I used virtualenv and pyhton3.
Next, I knocked him out.
Dockerfile:

FROM ubuntu
COPY . .
RUN /bin/bash -c "source venv/bin/activate"
ENTRYPOINT /bin/bash -c "python3 index.py"

The build passed without problems:
(venv) [email protected] ~/python/bottler $ docker build -t bottler .
Sending build context to Docker daemon  26.07MB
Step 1/4 : FROM ubuntu
 ---> 7698f282e524
Step 2/4 : COPY . .
 ---> 9e182c969051
Step 3/4 : RUN /bin/bash -c "source venv/bin/activate"
 ---> Running in 2022e2fa7600
Removing intermediate container 2022e2fa7600
 ---> 16209d249539
Step 4/4 : ENTRYPOINT python3 index.py
 ---> Running in 84594de70d72
Removing intermediate container 84594de70d72
 ---> d5057555ab1a
Successfully built d5057555ab1a
Successfully tagged bottler:latest

Next, I try to run the container like this:
docker run -i -t --rm -p 8000:8000 bottler
But I get the following error message:
/bin/bash: python3: command not found
Please help me run this application on the local machine in such a way that the result is visible in the browser at a specific address

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Kitaev, 2019-06-17
@zlodiak

1) replace ENTRYPOINT with CMD and read about the difference
2) Inherit from python:3.7, not from ubuntu
3) Do not sculpt a virtual environment in a docker image

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question