Search code examples
dockerfilecontainersclickhouse

Where is the config.xml from when clickhouse container starts up?


questions about the dockerfile of clickhouse server

I wonder where the /etc/clickhouse/config.xml is from when building the image

I read the dockerfile and entrypoint.sh from master branch of clickhouse dockerfile, entrypoint.sh

If I don't set build-arg deb_location_url and single_binary_location_url when building the image, so it goes to this code block.

else
mkdir -p /etc/apt/sources.list.d
apt-key adv --keyserver keyserver.ubuntu.com --recv 8919F6BD2B48D754
echo ${REPOSITORY} > /etc/apt/sources.list.d/clickhouse.list
echo "installing from repository: ${REPOSITORY}"
apt-get update
apt-get --yes -o "Dpkg::Options::=--force-confdef" -o "Dpkg::Options::=--force-confold" upgrade
for package in ${PACKAGES}; do
packages="${packages} ${package}=${VERSION}"
done
apt-get install --allow-unauthenticated --yes --no-install-recommends ${packages} || exit 1
fi \

And after that I don't find where the config.xml is from because in entrypoint.sh, it uses this file to get DATA_DIR and something else. And actually I build this image and docker run it, the container exits and logs like not found the file config.xml.

I'm confused about it, I am new to docker, I wonder if I missed some command that makes config.xml generated at container startup. Can someone tells me what's wrong with me, thanks a lot


Solution

  • As Denny said, it is there. During the docker build you should see the ClickHouse deb repository get added and then clickhouse-server and client debs get installed. The default config is installed then. There is also a docker-related.xml that gets copied from the local disk during the build and placed in /etc/clickhouse-server/config.d/

    I moved the Dockerfile.ubuntu out of the docker dir so I could watch what happens with no assumptions; here is my history:

    mkdir /tmp/container
    cp Dockerfile.ubuntu /tmp/container/Dockerfile
    cd /tmp/container
    docker build --network=host -t dockertest .
    cp /work/Docs/ClickHouse/docker/server/entrypoint.sh .
    cp /work/Docs/ClickHouse/docker/server/docker_related_config.xml .
    docker build --network=host -t dockertest .
    
    docker run -it --network host dockertest bash
    # Since you are new to Docker, adding `bash` at the
    # end of the command gives a bash shell in the container.
    # I use this to look around.
    
    # the default config.xml is in /etc/clickhouse-server/
    # and the docker-related.xml is in 
    # /etc/clickhouse-server/config.d/
    
    docker run -it --network host dockertest
    clickhouse client
    

    For more Docker examples, see https://github.com/ClickHouse/examples/tree/main/docker-compose-recipes