Vyacheslav February 2016

Docker-machine ip in Dockerfile

I have a Spring boot project with Docker. My Dockerfile like this:

...<many useful info>...
CMD ["java", "-Djava.rmi.server.hostname=<DOCKER_CONTAINER_IP>", "javafile.jar"]

I need set DOCKER_CONTAINER_IP (ip of docker container which I can get by docker-machine ip default) when I run Docker.
How can I do it?

Answers


taco February 2016

Use environment variables.

https://docs.docker.com/engine/reference/run/#env-environment-variables

docker run -e DOCKER_CONTAINER_IP=a.b.x.y mycontainer

If you need to specify them in your Dockerfile:

https://docs.docker.com/engine/reference/builder/

FROM someimage
ENV DOCKER_CONTAINER_IP a.b.x.y

Post Status

Asked in February 2016
Viewed 3,121 times
Voted 6
Answered 1 times

Search




Leave an answer