# Install other software during docker image build

**URL:** <https://forum.ansible.com/t/install-other-software-during-docker-image-build/34340>\
**Category:** AWX Project\
**Tags:** awx, kubernetes\
**Created:** [December 16, 2020, 1:33am UTC](https://forum.ansible.com/t/install-other-software-during-docker-image-build/34340 "2020-12-16T01:33:36Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cnu\_k](https://avatars.discourse-cdn.com/v4/letter/c/a88e4f/32.png) [@Cnu\_k](https://forum.ansible.com/u/Cnu_k)\
**Post date:** [December 16, 2020, 1:33am UTC](https://forum.ansible.com/t/install-other-software-during-docker-image-build/34340/1 "2020-12-16T01:33:36Z")

</div>

Hi,

I am able to build my own docker image by updating inventory file entries, but having issues when I tried to install following tools by adding these entries to awx/blob/devel/installer/roles/image\_build/templates/Dockerfile.j2 file.

RUN dnf install -y jq  
RUN dnf install -y wget  
RUN dnf install -y gcc

Added these entries in different sections of the file and still no luck. I see other tools in “Install runtime requirements” and other sections, so not sure why the resulted awx-web image/container doesn’t have these installed. I don’t see any errors either during install process.

Also commented to run as root and that too didn’t work as I still see the user as ‘awx’ when I got shell into the awx-web container in my Kubernetes environment.

Any clues will be appreciated.

Thanks

---

<div class="post-metadata">

**Author:** ![Nicolas\_G](https://avatars.discourse-cdn.com/v4/letter/n/a183cd/32.png) [@Nicolas\_G](https://forum.ansible.com/u/Nicolas_G)\
**Post date:** [December 16, 2020, 5:21pm UTC](https://forum.ansible.com/t/install-other-software-during-docker-image-build/34340/2 "2020-12-16T17:21:06Z")

</div>

Hi Cnu,

Where exactly have you tried adding these entries? it seems for some of them you must have a specific flag set like **build\_dev** in [https://github.com/ansible/awx/blob/devel/installer/roles/image\_build/templates/Dockerfile.j2#L93](https://github.com/ansible/awx/blob/devel/installer/roles/image_build/templates/Dockerfile.j2#L93).

I’ve tried a different route creating my own docker image by using docker directly without the installer.

For example create a docker file that will look like this:

Dockerfile:

```auto
FROM ansible/awx:14.1.0

USER root

RUN dnf install -y jq
RUN dnf install -y wget
RUN dnf install -y gcc

```

Build the image and push it to a registry :

```auto

docker build --tag my_awx:14.1.0_myversion --file Dockerfile .
docker tag my_awx:14.1.0_myversion myprivate.registry.com/awx:14.1.0_myversion
docker push myprivate.registry.com/awx:14.1.0_myversion

```

You then need to update the ansible installer to pull that image instead of the public one.

Hope that helps.

---

<div class="post-metadata">

**Author:** ![howardjones](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/howardjones/32/4169_2.png) [@howardjones](https://forum.ansible.com/u/howardjones)\
**Post date:** [December 16, 2020, 5:26pm UTC](https://forum.ansible.com/t/install-other-software-during-docker-image-build/34340/3 "2020-12-16T17:26:41Z")

</div>

Be aware that there are TWO docker containers built by that Dockerfile! The first one is used to build python packages for use by the second. Somewhere around line 100 or so you will see a second “FROM” line. That’s the start of the build for the container that is actually pushed. Below that are a series of COPY commands pulling the venv and some other things from the first container.

---

<div class="post-metadata">

**Author:** ![Cnu\_k](https://avatars.discourse-cdn.com/v4/letter/c/a88e4f/32.png) [@Cnu\_k](https://forum.ansible.com/u/Cnu_k)\
**Post date:** [December 16, 2020, 8:25pm UTC](https://forum.ansible.com/t/install-other-software-during-docker-image-build/34340/4 "2020-12-16T20:25:30Z")

</div>

Right, there are 2 FROM lines. I tried adding below statements under and outside as well after the 2nd ‘FROM’ image build.

RUN dnf install -y jq  
RUN dnf install -y wget

I will check again, if not, will try your route mentioned above. I was trying to build by adding few extra tools to the main Dockerfile template but it doesn’t appear to be working.

Thanks

---

<div class="post-metadata">

**Author:** ![Cnu\_k](https://avatars.discourse-cdn.com/v4/letter/c/a88e4f/32.png) [@Cnu\_k](https://forum.ansible.com/u/Cnu_k)\
**Post date:** [December 17, 2020, 2:47am UTC](https://forum.ansible.com/t/install-other-software-during-docker-image-build/34340/5 "2020-12-17T02:47:11Z")

</div>

I do see above commands in the Dockerfile generated from the template but don’t see jq or wget utilities when I run ‘which jq’ and ‘which wget’.

---

<div class="post-metadata">

**Author:** ![Ankit2](https://avatars.discourse-cdn.com/v4/letter/a/ea5d25/32.png) [@Ankit2](https://forum.ansible.com/u/Ankit2)\
**Post date:** [December 17, 2020, 6:50am UTC](https://forum.ansible.com/t/install-other-software-during-docker-image-build/34340/6 "2020-12-17T06:50:51Z")

</div>

I don’t think even which is going to work but, i remember gcc is part of the default dockerfile which is required to compile the code. Is there any specific error you are getting while building it. For me, it works simply by adding RUN commands in Dockerfile.j2.

---

<div class="post-metadata">

**Author:** ![Cnu\_k](https://avatars.discourse-cdn.com/v4/letter/c/a88e4f/32.png) [@Cnu\_k](https://forum.ansible.com/u/Cnu_k)\
**Post date:** [December 17, 2020, 7:09am UTC](https://forum.ansible.com/t/install-other-software-during-docker-image-build/34340/7 "2020-12-17T07:09:59Z")

</div>

Good to know that it’s working for you. I do see which command working for other software that’s in Install section. I don’t see any error or warning messages, the image building fails if I mention‘net stat’ command since it’s not in the yum or dnf repo.  
Other than that I have not seen anything.  
I will try to build another image manually by using the generated Dockefile and see if it works.

Thanks

---

<div class="post-metadata">

**Author:** ![Cnu\_k](https://avatars.discourse-cdn.com/v4/letter/c/a88e4f/32.png) [@Cnu\_k](https://forum.ansible.com/u/Cnu_k)\
**Post date:** [December 17, 2020, 4:02pm UTC](https://forum.ansible.com/t/install-other-software-during-docker-image-build/34340/8 "2020-12-17T16:02:17Z")

</div>

Not sure if the issue is related to below Anisble task in [https://github.com/ansible/awx/blob/devel/installer/roles/image\_build/tasks/main.yml](https://github.com/ansible/awx/blob/devel/installer/roles/image_build/tasks/main.yml) or docker\_image Ansible module as I manually built a awx-web image with the same Dockerfile that’s used by docker\_image module and I do see jq, nano, wget, and lsof installed there when I ran docker exec commands. The tools are there in ‘yum list installed’ list as well.

- name: Build base awx image  
docker\_image:  
build:  
path: “{{ docker\_base\_path }}”  
dockerfile: Dockerfile  
pull: false  
args:  
http\_proxy: “{{ http\_proxy | default(‘’) }}”  
https\_proxy: “{{ https\_proxy | default(‘’) }}”  
no\_proxy: “{{ no\_proxy | default(‘’) }}”  
name: “{{ awx\_image }}”  
tag: “{{ awx\_version }}”  
source: ‘build’  
force\_source: true  
delegate\_to: localhost

I will keep trying different options to make it work.

---

<div class="post-metadata">

**Author:** ![Cnu\_k](https://avatars.discourse-cdn.com/v4/letter/c/a88e4f/32.png) [@Cnu\_k](https://forum.ansible.com/u/Cnu_k)\
**Post date:** [December 30, 2020, 4:38pm UTC](https://forum.ansible.com/t/install-other-software-during-docker-image-build/34340/9 "2020-12-30T16:38:53Z")

</div>

I gave up on building my own image as our corporate network has so many restrictions to install pip, npm and other open source packages.  
@ Nicolas G, I have created my own image by adding jq, wget off of base AWX image and pushed to our private registry.  
What changes need to be made to Anisble playbook or inventory fiiles to use that image instead of the docker hub public AWX image?

Thanks
