Creating a Docker Container to Run AS3 Declarations
Hi,
Very nice article! Not easy to figure out for beginner like me, so have few questions.
I am maybe wrong but there are some missing pieces and small errors:
In installation section after
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
it seems that sudo apt-get update
is missing. Without this step Docker install failed on my side (but I am using Ubuntu 16.0.4)
In Python script there is typo (at least without correction I was not able to run this script)
Check we have connectivity and AS3 is installed
print(' Checking that AS3 is running on ', IP ,' ')
url = URLBASE + TESTPATH>
I changed it to:
url = URLBASE + TESTPATH
- so > should be removed?
I was not as well sure how to perform docker build command. My steps were:
- Created as3 folder in home
- Placed as3.py, Dockerfile and requirements.txt in this folder
- cd as3
-
Run your version of command - it failed with message about missing arguments (if I can recall)
So I used this version (added dot):
docker build . -t runciblespoon/as3_python:A --build-arg Username=$XUSER --build-arg Password=$XPASS
Wonder if my corrections are OK?
I have as well few questions about how your example can be modified. Just would like to make it more generic/universal:
Passing BIG-IP MGMT IP:port to the Python script. I think it can be done using similar approach as for Username and Password via
--build-arg
, just not sure what needs to be modified. My guess is I should add something like that in Dockerfile:
ARG Mgmntip=10.10.10.10
ENV XIP=$Mgmntip
then in python script:
IP = os.environ['XIP']
and finally in
docker build
command add --build-arg Mgmtip=192.168.10.1
I am not sure if this is necessary to use
export XIP=192.168.10.1
and then in --build-arg Mgmtip=$XIP
?
If above is correct then I assume that same approach can be taken to pass GITDRC? Something like (in python script):
GITDRC = 'https://raw.githubusercontent.com/RuncibleSpoon/as3/master/declarations/' + os.environ['XJSON']
of course after XJSON is set in Dockerfile and passed via
--build-arg
Last but not least, in Dockerfile there is:
ARG DecURL=https://raw.githubusercontent.com/RuncibleSpoon/as3/master/declarations/payload.json
ENV Declaration=$DecURL
Is that used anywhere?
Sorry for so many questions but as I said it's all new to me.
EDIT: You can disregard my questions about passing values at
docker build
stage - checked and it's working 🙂
But it is not as universal as I expected, so question is if there is a way to pass arguments at the
docker run
stage?
EDIT 2: Quite stupid to answer own questions 🙂 Figured out how to pass all necessary vars at
docker run
stage, just used --env-file
, working like a charm!
Piotr