titlesidebar_labeldescription
Get started with QuestDB via Docker
Docker
Guide showing how to use QuestDB with Docker. This also covers how to import data as well as persistence.

QuestDB has images for both Linux/macOS and Windows on Docker Hub.

Install Docker

Before we start, you will need to install Docker. You can find guides for your platform on the official documentation.

QuestDB image

Once Docker is installed, you will need to pull QuestDB’s image from Docker Hub and create a container. You can do both in one command using docker run:

  1. docker run -p 9000:9000 \
  2. -p 9009:9009 \
  3. -p 8812:8812 \
  4. -p 9003:9003 \
  5. questdb/questdb

Options

ArgumentDescription
-pPort to publish to the host
-vTo bind mount a volume

-p parameter

This parameter will publish a port to the host, you can specify:

-v volumes

The QuestDB root_directory will be in the following location:

  1. /root/.questdb
  1. C:\questdb

Container status

You can check the status of your container with docker ps. It also lists the ports we published:

  1. docker ps
  1. CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
  2. dd363939f261 questdb/questdb "/app/bin/java -m io…" 3 seconds ago Up 2 seconds 8812/tcp, 9000/tcp frosty_gauss

Importing data and sending queries

Now that QuestDB is running, you can start interacting with it:

  • If you published the port 9000, you can follow our REST page
  • If you published the port 8812, follow our Postgres page
  • If you published the port 9009, follow our InfluxDB page

Data persistence

Mounting a volume

Volumes can be mounted to the QuestDB Docker container so that data may be persisted or server configuration settings may be passed to an instance. The following example demonstrated how to mount the current directory to a QuestDB container using the -v flag in a Docker run command:

  1. docker run -p 9000:9000 \
  2. -p 9009:9009 \
  3. -p 8812:8812 \
  4. -p 9003:9003 \
  5. -v "$(pwd):/root/.questdb/" questdb/questdb

The current directory will then have data persisted to disk for convenient migration or backups:

  1. ├── conf
  2. └── server.conf
  3. ├── db
  4. └── public

For details on passing QuestDB server settings to a Docker container, see the Docker section of the server configuration documentation.

Writing logs to disk

When mounting a volume to a Docker container, a logging configuration file may be provided in the container located at /conf/log.conf:

  1. └── conf
  2. ├── log.conf
  3. └── server.conf

For example, a file with the following contents can be created:

  1. # list of configured writers
  2. writers=file,stdout,http.min
  3. # file writer
  4. w.file.class=io.questdb.log.LogFileWriter
  5. w.file.location=questdb-docker.log
  6. w.file.level=INFO,ERROR,DEBUG
  7. # stdout
  8. w.stdout.class=io.questdb.log.LogConsoleWriter
  9. w.stdout.level=INFO
  10. # min http server, used monitoring
  11. w.http.min.class=io.questdb.log.LogConsoleWriter
  12. w.http.min.level=ERROR
  13. w.http.min.scope=http-min-server

The current directory can be mounted:

  1. docker run -p 9000:9000 \
  2. -p 9009:9009 \
  3. -p 8812:8812 \
  4. -p 9003:9003 \
  5. -v "$(pwd):/root/.questdb/" questdb/questdb

The container logs will be written to disk using the logging level and file name provided in the conf/log.conf file, in this case in ./questdb-docker.log:

  1. ├── conf
  2. ├── log.conf
  3. └── server.conf
  4. ├── db
  5. ├── table1
  6. └── table2
  7. ├── public
  8. ├── ui / assets
  9. ├── ...
  10. └── version.txt
  11. └── questdb-docker.log

For more information on logging, see the configuration reference documentation.

Restart an existing container

Running the following command will create a new container for the QuestDB image:

  1. docker run -p 9000:9000 \
  2. -p 9009:9009 \
  3. -p 8812:8812 \
  4. -p 9003:9003 \
  5. questdb/questdb

By giving the container a name with --name container_name, we have an easy way to refer to the container created by run later on:

  1. docker run -p 9000:9000 \
  2. -p 9009:9009 \
  3. -p 8812:8812 \
  4. -p 9003:9003 \
  5. --name docker_questdb \
  6. questdb/questdb

If we want to re-use this container and its data after it has been stopped, we can use the following commands:

  1. # bring the container up
  2. docker start docker_questdb
  3. # shut the container down
  4. docker stop docker_questdb

Alternatively, users can obtain a running container’s ID with ‘docker ps’ and restart it using the UUID short identifier:

  1. docker start dd363939f261