'Overwrite file in Docker Container

I have jira8 running in a docker container:

jira8:
  container_name: jira8
  expose:
    - "8080"
  image: atlassian/jira-software:8.10
  networks:
    atlassian-network:
      aliases:
        - jira8
  ports:
    - "8081:8080"
  restart: always
  volumes:
    - /Users/mles/git/jira-migration/config-files/server-localhost-8.10.xml:/opt/atlassian/jira/conf/server.xml

Everytime I restart the docker container, the file /Users/mles/git/jira-migration/config-files/server-localhost-8.10.xml gets overwritten with the file present at /opt/atlassian/jira/conf/server.xml in the jira8 docker container.

I could - after the start of the container - copy the server-localhost-8.10.xml manually into the docker container, overwriting the default server.xml.

I tried mounting read only (:ro)

  volumes:
    - /Users/mles/git/jira-migration/config-files/server-localhost-8.10.xml:/opt/atlassian/jira/conf/server.xml:ro

but my file on the host still gets overwritten.

Is there a better way to do this? f.ex. making the mounted files read only and always overwriting the files present in the docker container?



Solution 1:[1]

You'll need to use this image's native setup system, or heavily patch it.

The image has a Docker Hub page (in general, https://hub.docker.com/r/owner/image for non-library images). That links to a Bitbucket repo for its Docker packaging source. The main container process is an entrypoint.py script that unconditionally does:

gen_cfg('server.xml.j2', f'{JIRA_INSTALL_DIR}/conf/server.xml')

where that gen_cfg function will overwrite the named output file by rendering it from the referenced Jinja2 source file.

The Docker Hub page lists out a pretty large number of environment-variable settings. If you set those, the container will produce its own server.xml file for you. If you can figure out what exactly is being injected, you can also use a bind mount to overwrite the server.xml.j2 source file.

(In general, bind mounts at startup time always push content into the container, and never extract content from the image. This image is slightly unusual in generating its own configuration and that's why the host file is getting overwritten; it's not something that naturally happens with Docker.)

Solution 2:[2]

I guess you want change Reverse Proxy Settings

add environment to your docker-compose.yml

 environment:
      - ATL_PROXY_NAME=jira.example.com
      - ATL_PROXY_PORT=443
      - ATL_TOMCAT_SCHEME=https

via https://hub.docker.com/r/atlassian/confluence-server/

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 David Maze
Solution 2 Lait