Mounting a host volume

Hi all. Hopefully a straightforward question to those that have had more exposure to AWX than I…

I have AWX installed, successfully, using local Docker/DB. I am wanting to add a host volume so that I can access certain files within the AWX containers.

These are software installation files, that I don’t really want to add to my Git repository, due to their size.

I added volume mounts in the default docker-compose.yml I use to stop/start the containers (/software) but they don’t appear to do anything/get ignored:

`

web:
image: ansible/awx_web:4.0.0
container_name: awx_web
depends_on:

  • rabbitmq
  • memcached
  • postgres
    ports:
  • “80:8052”
    hostname: awxweb
    user: root
    restart: unless-stopped
    volumes:
    - /software:/software
  • “/tmp/awxcompose/SECRET_KEY:/etc/tower/SECRET_KEY”
  • “/tmp/awxcompose/environment.sh:/etc/tower/conf.d/environment.sh”
  • “/tmp/awxcompose/credentials.py:/etc/tower/conf.d/credentials.py”
    environment:
    http_proxy:
    https_proxy:
    no_proxy:

task:
image: ansible/awx_task:4.0.0
container_name: awx_task
depends_on:

  • rabbitmq
  • memcached
  • web
  • postgres
    hostname: awx
    user: root
    restart: unless-stopped
    volumes:
    - /software:/software
  • “/tmp/awxcompose/SECRET_KEY:/etc/tower/SECRET_KEY”
  • “/tmp/awxcompose/environment.sh:/etc/tower/conf.d/environment.sh”
  • “/tmp/awxcompose/credentials.py:/etc/tower/conf.d/credentials.py”
    environment:
    http_proxy:
    https_proxy:
    no_proxy:


`

I am new to Docker/AWX. What I am doing wrong?

That configuration is where you attach the volumes to the containers. There should be another section where the volumes are defined. It’s usually further down the file after all the containers. Search for one of the other volumes and you should see where to put it and use the other volumes as examples.

Dave

Hi Dave, thanks for taking the time to reply.

The configuration listed is the default docker-compose.yml in /tmp/awxcompose and there are no further volume configurations/declarations, other than those defined within the services. I post here the full version:

`
version: ‘2’
services:

web:
image: ansible/awx_web:4.0.0
container_name: awx_web
depends_on:

  • rabbitmq
  • memcached
  • postgres
    ports:
  • “80:8052”
    hostname: awxweb
    user: root
    restart: unless-stopped
    volumes:
  • /software:/software
  • “/tmp/awxcompose/SECRET_KEY:/etc/tower/SECRET_KEY”
  • “/tmp/awxcompose/environment.sh:/etc/tower/conf.d/environment.sh”
  • “/tmp/awxcompose/credentials.py:/etc/tower/conf.d/credentials.py”
    environment:
    http_proxy:
    https_proxy:
    no_proxy:

task:
image: ansible/awx_task:4.0.0
container_name: awx_task
depends_on:

  • rabbitmq
  • memcached
  • web
  • postgres
    hostname: awx
    user: root
    restart: unless-stopped
    volumes:
  • /software:/software
  • “/tmp/awxcompose/SECRET_KEY:/etc/tower/SECRET_KEY”
  • “/tmp/awxcompose/environment.sh:/etc/tower/conf.d/environment.sh”
  • “/tmp/awxcompose/credentials.py:/etc/tower/conf.d/credentials.py”
    environment:
    http_proxy:
    https_proxy:
    no_proxy:

rabbitmq:
image: ansible/awx_rabbitmq:3.7.4
container_name: awx_rabbitmq
restart: unless-stopped
environment:
RABBITMQ_DEFAULT_VHOST: “awx”
RABBITMQ_DEFAULT_USER: “guest”
RABBITMQ_DEFAULT_PASS: “awxpass”
RABBITMQ_ERLANG_COOKIE: cookiemonster

memcached:
image: memcached:alpine
container_name: awx_memcached
restart: unless-stopped

postgres:
image: postgres:9.6
container_name: awx_postgres
restart: unless-stopped
volumes:

  • /tmp/pgdocker:/var/lib/postgresql/data:Z
    environment:
    POSTGRES_USER: awx
    POSTGRES_PASSWORD: awxpass
    POSTGRES_DB: awx
    PGDATA: /var/lib/postgresql/data/pgdata

`

According to the docker compose documentation (see “volumes”), what I have done looks to be correct? I seem to be missing something pretty fundamental, probably due to my lack of experience.

If you, or anyone else, has successfully achieved this with AWX, I’d love to learn how.

Thanks,

Toby.

I have not used the container mount directive as i did not want to modify the file since i update the AWX servers regularly. I simply loaded my files that i did not want to have in the GIthub Repository into the Docker hosts /var/lib/awx/projects Directory. I have a few directories there that i utilize for Scripts, Documentation, and Binary’s that i use within my playbooks.

This I am sure is not the correct way to utilize the directory but it is how you manage local Git repos and i have had great success with it. You could look for the section of the compose file that has this directory path and possibly just add an addition to meet your requirements.

Thanks for sharing your experience Micah. I really think what I am trying to do should be possible, and I don’t understand why it’s not working.

I just perform a bind mount using a different docker-compose.yml file, with an Ubuntu container, on the same machine, and it works just fine:

`
myhost → cat docker-compose.yml
version: ‘2’
services:

test:
image: ubuntu:14.04
container_name: test
restart: unless-stopped
entrypoint: tail -f /dev/null
volumes:

  • /software:/software

myhost → docker-compose start
Starting test … done

myhost → docker exec -it test /bin/bash
root@273c72e0f914:/# df
Filesystem 1K-blocks Used Available Use% Mounted on
overlay 66581072 27549272 39031800 42% /
tmpfs 4078992 0 4078992 0% /dev
tmpfs 4078992 0 4078992 0% /sys/fs/cgroup
/dev/mapper/swvg-swlv 123723328 84848164 32881932 73% /software
/dev/sda2 66581072 27549272 39031800 42% /etc/hosts
shm 65536 0 65536 0% /dev/shm
tmpfs 4078992 0 4078992 0% /proc/acpi
tmpfs 4078992 0 4078992 0% /proc/scsi
tmpfs 4078992 0 4078992 0% /sys/firmware
root@273c72e0f914:/# ll /software
total 44
drwxr-xr-x 9 root root 4096 Oct 2 2018 ./
drwxr-xr-x 1 root root 33 Apr 26 12:10 …/
drwxr-xr-x 2 root root 4096 May 23 2018 Couchbase/
drwxr-xr-x 2 root root 4096 Jun 5 2018 GE_Software/
drwxr-xr-x 6 root root 4096 Apr 24 11:01 GIT_repositories/
drwxr-xr-x 10 root root 4096 Oct 3 2018 IBM_Software/
drwxr-xr-x 5 root root 4096 Apr 25 13:00 Oracle_Software/
drwxr-xr-x 2 root root 4096 Jul 24 2018 RedHat_Cloudforms/
drwxr-xr-x 2 root root 16384 Dec 18 2017 lost+found/
`

Is anyone else able to help?

``

Oh my, it appears I hadn’t realised the difference between docker-compose ‘up’ vs ‘start’!

Modifying the docker-compose.yml file with the required volumes and running ‘docker-compose up -d’ to rebuild/start the images has resolved my issue.

I knew it was something silly.

Thanks to those who responded.