To install a custom package or modify an existing docker image we need to
- run a docker a container from the image we wish to modify
- modify the docker container
- commit the changes to the container as a docker image
- test changes made to image
The command to do this is,
docker run -it yhat/scienceops-python:0.0.2 /bin/bash
-
The -i tells docker to attach stdin to the container
-
The -t tells docker to give us a pseudo-terminal
-
/bin/bash will run a terminal process in your container
Once we are in our container we can install package(s), and set environment variables
$ sudo apt-get install vim
$ export AWS_SECRET_KEY=mysecretkey123
$ export AWS_ACCESS_KEY=fooKey
When you are done modifying your container you must exit by running the
exit
command. Once we exit the container, we need to find the
container ID by running
docker ps -a
Copy the container ID for the container you just modified, and then run
the docker commit
command to commit changes to your container as an image.
docker commit [options] [container ID] [repository:tag]
An example docker commit
command is the following.
docker commit e8f0671518a2 yhat/scienceops-python:0.0.2
Note here! You must commit the changes with the same tags as the scienceops image on your system. To see your new image run.
docker images
To test your changes when adding an environment variable run the test command
$ docker run -it yhat/scienceops-python:0.0.2 echo $AWS_SECRET_KEY
Thanks