Docker Run Commands

Docker Run Commands

September 18, 2024

Sometimes I work with Docker every day for a few weeks, but then I don’t need to touch it again for months at a time. I don’t think my story is unique there - my role isn’t in DevOps, so I figure out what I need, save the commands to a note somewhere, and move along.

Most often I use Microsoft SQL Server at work and PostgreSQL on personal projects, so I tend to keep copies of those commands in different notes. I want to collect my most frequently used ones here.

All of the volume mounts here are meant to be used with Named Volumes. I’ve tried to move all of my stuff away from bind-mounts. Check out my post on Named Volumes, or take a look at the Docker Docs for more details.

Pulling the Latest Images

docker pull postgres:latest
docker pull mcr.microsoft.com/mssql/server:2022-latest

I tend to forget the naming convention for Microsoft’s container registry. You can substitute the 2022 for a different version offered by Microsoft.

Source

docker pull clickhouse/clickhouse-server

Run Commands

Bash
docker run --name pg \
  -p 5432:5432 \
  -e POSTGRES_PASSWORD=<secret> \
  -v pgdata:/var/lib/postgresql/data \
  -d postgres

Source

Bash
docker run --name mssql22 \
    -p 1433:1433 \
    -e "ACCEPT_EULA=Y" \
    -e "MSSQL_SA_PASSWORD=<secret>" \
    -v mssql_data:/var/opt/mssql \
    -d mcr.microsoft.com/mssql/server:2022-latest

Source

docker run --name clickhouse \
  -p 9000:9000 \
  -e CLICKHOUSE_USER=my_user \
  -e CLICKHOUSE_PASSWORD=<secret> \
  -e CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT=1 \
  -v ch_data:/var/lib/clickhouse/ \
  -v ch_logs:/var/log/clickhouse-server/ \
  -d clickhouse/clickhouse-server:latest

Source

Last updated on