Docker noob here...
I am trying to build and run an IBM DataPower container from a Dockerfile, but it doesn't seem to work the same as when just running docker run
and passing the same parameters in the terminal.
This works (docker run
)
docker run -it \
-v $PWD/config:/drouter/config \
-e DATAPOWER_ACCEPT_LICENSE=true \
-e DATAPOWER_INTERACTIVE=true \
-e DATAPOWER_WORKER_THREADS=4 \
-p 9090:9090 \
--name mydatapower \
ibmcom/datapower
... the key part being that it mounts the ./config
folder and the custom configuration is picked up by datapower running in the container.
This doesn't (Dockerfile
)
Dockerfile:
FROM ibmcom/datapower
ENV DATAPOWER_ACCEPT_LICENSE=true
ENV DATAPOWER_INTERACTIVE=true
ENV DATAPOWER_WORKER_THREADS=4
EXPOSE 9090
COPY config/auto-startup.cfg /drouter/config/auto-startup.cfg
Build:
docker build -t local/datapower .
Run:
docker run -it \
-p 9090:9090 \
--name mydatapower local/datapower
The problem is that DataPower doesn't pick up the auto-startup.cfg
file, so the additional config options doesn't get used. I know the source file path is correct because if I misspell the file name docker throws an error.
I have a theory that it might be running the inherited ENTRYPOINT or CMD before the config file is available. I don't know how to test or prove this. I don't know what the ENTRYPOINT or CMD is because the inherited image is not open source and I can't figure out how to find it.
Does that seem likely?
UPDATE:
The content of the auto-startup.cfg
is:
top; co
ssh
web-mgmt
admin enabled
port 9090
exit
It simply enables the DataPower WebGUI.
The output when running it in the commandline with:
docker run -it -v $PWD/config:/drouter/config -v $PWD/local:/drouter/local -e DATAPOWER_ACCEPT_LICENSE=true -e DATAPOWER_INTERACTIVE=true -e DATAPOWER_WORKER_THREADS=4 -p 9091:9090 --name myconfigureddatapower ibmcom/datapower`
...contains this:
20170908T121729.015Z [0x8100006e][system][notice] : Executing startup configuration.
20170908T121729.970Z [0x00350014][mgmt][notice] web-mgmt(WebGUI-Settings): tid(303): Operational state up
...but with Dockerfile
it doesn't. That's why I think the config files may be copied into place too late.
I've tried adding CMD ["/bin/drouter"]
to the end of my Dockerfile to no avail.
I have tested your Dockerfile and it seems to be working. My
auto-startup.cfg
file is copied in the proper location and when I launch the container it's reading the file.I get this output:
To check that your file has been copied to the container you can run
docker run -ti local/datapower sh
to enter the container and then check the content of/drouter/config/
.Your base image command is:
CMD ["/bin/drouter"]
you can check it runningdocker history ibmcom/datapower
.UPDATE:
The
drouter
user in the container must be able to read theauto-startup.cfg
file. You have 2 options:auto-startup.cfg
with the proper permissions (chmod 644 config/autostart.cfg
).or add these line in the Dockerfile so
drouter
can read the file: