I’m running clickhouse on a docker container and mounted volumes on an external harddrive:
sudo docker run --name clickhouse-server
--ulimit nofile=262144:262144
-p 18123:8123
-p 19000:9000
-p 19009:9009
-v ./clickhouse:/var/lib/clickhouse
-v ./clickhouse-server:/var/log/clickhouse-server
-dit clickhouse/clickhouse-server
I installed clickhouse-client
using apt
and this seems to assume that clickhouse is installed locally.
When I run
clickhouse-client
--port 19000
--input_format_csv_skip_first_lines 1
--date_time_input_format 'best_effort'
-q "INSERT INTO mytable FROM INFILE './data/mytable_data1.csv.gz'"
This raises the following error:
DB::Exception: Received from localhost:19000.
DB::ErrnoException. DB::ErrnoException: Cannot set modification time
for file: /var/lib/clickhouse/store/18d/18d1dbb9-3d04-4a43-b9f3-8393420d1c8b/tmp_insert_all_3_3_0/,
errno: 1, strerror: Operation not permitted. (PATH_ACCESS_DENIED)
I believe /var/lib/clickhouse
should be redirected to my docker volume mount path /media/user/data/clickhouse
.
Simple queries such as SHOW TABLES
seem to work fine:
clickhouse-client --port 19000 -q "show tables"
Any suggestions would be much appreciated!
2
Answers
I got it to work. You have to use the
-u
option to specify the user ID and group id of the user that owns the mounted directory on the host system.When you run the docker container, you need to mount the directory with the correct permission. The above command mounts the
/media/user/data/clickhouse
directory on the host system to/var/lib/clickhouse
inside the container and sets the user ID and group ID of the container to match the owner of the mounted directory on the host system.I would exec a shell in the container and check the owner and perms on /var/lib/clickhouse/store and the id of the clickhouse server process.