0

I built a docker image using the following Dockerfile:

FROM continuumio/miniconda3

ENTRYPOINT [ “/bin/bash”, “-c” ]

ADD angular_restplus.yaml angular_restplus.yaml

RUN ["conda", "env", "create", "-f", "angular_restplus.yaml"]

RUN ["/bin/bash", "-c", "source activate work"]

COPY json_to_db.py json_to_db.py

CMD ["gunicorn", "-b", "0.0.0.0:3000", "json_to_db:app"]

and command to build it:

sudo docker build -t testimage:latest .

That runs through:

Step 5/7 : RUN ["/bin/bash", "-c", "source activate work"]
 ---> Running in 45c6492b1c67
Removing intermediate container 45c6492b1c67
 ---> 5b5604dc281d
Step 6/7 : COPY json_to_db.py json_to_db.py
 ---> e5d05858bed1
Step 7/7 : CMD ["gunicorn", "-b", "0.0.0.0:3000", "json_to_db:app"]
 ---> Running in 3ada6fd24d09
Removing intermediate container 3ada6fd24d09
 ---> 6ed934acb671
Successfully built 6ed934acb671
Successfully tagged testimage:latest

However, when I now try to use it, it does not work; I tried:

sudo docker run --name testimage -d -p 8000:3000 --rm testimage:latest

which seems to work fine as it prints

b963bdf97b01541ec93e1eb7

However, I cannot access the service in my browser and using

sudo docker ps -a

only shows the intermediate containers needed to create the image from above.

When I try to run it without the -d flag, I get

gunicorn: 1: [: “/bin/bash”,: unexpected operator

Does that mean that I have to change the ENTRYPOINT again? If so, to what?

Cleb
  • 25,102
  • 20
  • 116
  • 151
  • Comments are not for extended discussion; this conversation has been [moved to chat](https://chat.stackoverflow.com/rooms/188182/discussion-on-question-by-cleb-successful-built-docker-image-does-not-run). –  Feb 10 '19 at 15:56

1 Answers1

1

The solution can be found in the following post. I had to use the

"/bin/bash", "-c"

part throughout. The following works fine now (using also @larsks' input who deleted his answer meanwhile):

FROM continuumio/miniconda3

COPY angular_restplus.yaml angular_restplus.yaml
SHELL ["/bin/bash", "-c"] 
RUN ["conda", "env", "create", "-f", "angular_restplus.yaml"]
COPY json_to_db.py json_to_db.py
CMD source activate work; gunicorn -b 0.0.0.0:3000 json_to_db:app

Then one can run

docker build -t testimage:latest .

and finally

docker run --name testimage -d -p 3000:3000 --rm testimage:latest

If one now uses

docker ps -a

one will get the expected outcome:

CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
61df8ac0432c        testimage:latest    "/usr/bin/tini -- /b…"   16 seconds ago      Up 15 seconds       0.0.0.0:3000->3000/tcp   testimage

and can then access the service at

http://localhost:3000/
Cleb
  • 25,102
  • 20
  • 116
  • 151