Set or change the value of environment variable in docker
- Enter the following command into the vagrant console: docker ps (if you do not have administrator privileges, use sudo before this command and subsequent commands). You should see the following:
- Find the image for which you want to set or change the value of the environment variable.
- Enter the following command to stop the image in the docker: docker stop 3175fa203456 where 3175fa203456 – docker container id (see in the left column when called docker ps command).
- Run image and set a new or changed value using the command: docker run -d -t -i -e enviromentVariableName='value' DockerImage where DockerImage - value from IMAGE column when called docker ps command.
- If everything is ok you will see new container id.
Examples:
Use the following command to set environment variables for the database and enable debug mode:
docker run -d -t -i -e DB_USERNAME='folio_admin' -e DB_PORT='5432' -e DB_HOST='10.0.2.15' -e DB_DATABASE='okapi_modules' -e DB_PASSWORD='******' -e JAVA_DEBUG='true' -p 9173:8081 -p 5005:5005 folioci/edge-oai-pmh
where, JAVA_DEBUG='true' – enable debug mode on 5005 port (-p 5005:5005)
-p 9173:8081 – docker image port number (see in PORTS column when called docker ps command)
folioci/edge-oai-pmh - docker image (see in IMAGE column when called docker ps command)
If you need to connect to a remote database, then set the value of the remote host as in this command:
docker run -d -t -i -e DB_USERNAME='folio_admin' -e DB_PORT='5432' -e DB_HOST='*****' -e DB_DATABASE='okapi_modules' -e DB_PASSWORD='*******' -e JAVA_DEBUG='true' -p 9153:8081 -p 5005:5005 folioci/edge-oai-pmh
where, -e DB_HOST='*****' - full address of the remote host (before executing this command, check ping with the remote host).