elexis-eu / dictionary-service

ELEXIS implementation of the REST dictionary service
Apache License 2.0
2 stars 0 forks source link

Can't get Docker container to work #1

Closed jan-niestadt closed 5 years ago

jan-niestadt commented 5 years ago

I'm not particularly Docker savvy, but this seems like a very basic issue. I've loaded the example data with this command:

docker run -it --rm --name=elexis --volume ~/projects/elexis-dictionary-service/examples:/tmp/examples --publish 8000:8000 jmccrae/elexis-dictionary-service load /tmp/examples/example.json

That does say "Release is not specified or bad value, assuming PUBLIC" but it doesn't give any error messages, so I guess it worked.

Then I try to run the service:

sudo docker run -it --rm --name=elexis -p 8000:8000 jmccrae/elexis-dictionary-service start

The only output I get is this:

Starting server at 127.0.0.1:8000

If I now go to http://127.0.0.1:8000/, it says that the connection was reset. Any idea what's wrong here?

(BTW, I have compiled the Rust program instead and that works without any problems for me, but I'd like to know why I can't get the Docker container to work)

jmccrae commented 5 years ago

Hi Jan,

sudo docker run -it --rm --name=elexis -p 8000:9000 jmccrae/elexis-dictionary-service start

I think there is an error in this line, both numbers should be 8000

Regards, John

On Fri, 30 Aug 2019 at 11:08, Jan Niestadt notifications@github.com wrote:

I'm not particularly Docker savvy, but this seems like a very basic issue. I've loaded the example data with this command:

docker run -it --rm --name=elexis --volume ~/projects/elexis-dictionary-service/examples:/tmp/examples --publish 8000:8000 jmccrae/elexis-dictionary-service load /tmp/examples/example.json

That does say "Release is not specified or bad value, assuming PUBLIC" but it doesn't give any error messages, so I guess it worked.

Then I try to run the service:

sudo docker run -it --rm --name=elexis -p 8000:9000 jmccrae/elexis-dictionary-service start

The only output I get is this:

Starting server at 127.0.0.1:8000

If I now go to http://127.0.0.1:8000/, it says that the connection was reset. Any idea what's wrong here?

(BTW, I have compiled the Rust program instead and that works without any problems for me, but I'd like to know why I can't get the Docker container to work)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/elexis-eu/dictionary-service/issues/1?email_source=notifications&email_token=AAK2VZ67HQKYFGSFURKGNC3QHDWRBA5CNFSM4ISLVDYKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HINFSLQ, or mute the thread https://github.com/notifications/unsubscribe-auth/AAK2VZYIUWCWFMH5RPIRX2DQHDWRBANCNFSM4ISLVDYA .

jan-niestadt commented 5 years ago

Sorry, I made a typo in the issue; I used 8000:8000 originally.

Just to be sure I tried it again, with this command line:

sudo docker run -it --rm --name=elexis -p 8000:8000 jmccrae/elexis-dictionary-service start

Same result: connection was reset. Any suggestions are welcome.

jmccrae commented 5 years ago

Just made a commit to fix this. It turns out the issue is with the IP address used by the server, it should have been 0.0.0.0:8000

jan-niestadt commented 5 years ago

Thanks, but it's still not working for me I'm afraid. I'm sure I must be doing something wrong; as I said I don't know much about Docker.

I realized the way I was trying it before can't really work, because --rm in the first command removes the container after loading the data, which is pretty pointless. Instead I think I need to create a container, load the data into the container, then start the server inside the same container, but I'm not sure how to accomplish that. Do I need to create a Dockerfile that uses jmccrae/elexis-dictionary-service as a base, and have the load and start commands in that Dockerfile?

Or another approach might be to mount a volume in the directory where the SQLite database is created, so the database will persist after destroying the container. Is that the way to go, do you think?

Of course I realize it's not your job to teach me Docker :-) , but if you have the time, I would really appreciate some basic pointers.

jmccrae commented 5 years ago

Can you check that the container is being downloaded again. It may be a good idea to remove the existing image

docker rmi jmccrae/elexis-dictionary-service

If the container is updated it should now say

Starting server at 0.0.0.0:8000

You are right that the --rm option will lead to data loss, you can just manually delete the container when it is done. It is not possible to put SQlite into another container as it is integrated in the tool.

jan-niestadt commented 5 years ago

Thanks, that worked!

It still took me a bit of time to find the exact commands, though. Maybe it would be a good idea to include a simple recipe in the README that people who are unfamiliar with Docker can try? For example (feel free to change as necessary):

Ensure we have the latest version of the image:

docker pull jmccrae/elexis-dictionary-service

Create the container, mount a volume containing the example data and run the dictionary service:

docker run -it -d --name dictserv --volume /path/to/elexis-dictionary-service/examples:/tmp/examples --publish 8000:8000 jmccrae/elexis-dictionary-service start

Load the example data into the running service:

docker exec -it dictserv /bin/elexis-dictionary-service load /tmp/examples/example.json

Now the service, with the example data loaded, should be running at http://0.0.0.0:8000/.

Finally, to stop and remove the container:

docker stop dictserv 
docker rm dictserv