Docker: Getting started

Fast, secure remote Docker management with Stackhero for Docker

Welcome to the Stackhero documentation

Stackhero provides a ready-to-use Docker cloud CaaS (Containers as a Service) platform, designed for fast and reliable container deployments:

  • Deploy to production with a single docker-compose up. There is no extra setup: just start your containers.
  • Pick your own domain name, secured automatically with HTTPS (for example: https://api.your-company.com, https://www.your-company.com, or https://backoffice.your-company.com).
  • Benefit from strong performance and robust security on private, dedicated infrastructure.
  • Apply updates with one click for simple, low-effort maintenance.

You can have your containers live in production in about five minutes. Stackhero manages the infrastructure, updates, and security for you, so you can focus on delivering your applications. Read more about Docker CaaS cloud hosting.

Docker CLI should be installed on your computer. If you have not installed it yet, you can download it from the official Docker site: Docker Desktop.

With Stackhero for Docker, you can manage your containers remotely with the Docker CLI, just as you would locally. This means you keep your familiar workflow, but now you can run commands directly on your production-ready Docker server: securely and efficiently.

Docker "contexts" make this possible. Contexts let you tell the Docker CLI where to send your commands: to your local Docker daemon, or to your Stackhero for Docker instance. Switching contexts is fast and seamless.

To connect securely to your Stackhero for Docker instance, you need to install its certificates on your computer. These certificates handle authentication and encryption, so your connection stays private and protected.

You can use the following command to download and set up the certificates:

# HOST is your Docker instance domain name (<XXXXXX>.stackhero-network.com).
# SERVICE_ID is your Stackhero service ID.
# CERTIFICATES_PASSWORD is the password defined in your Docker configuration on Stackhero dashboard.
(export HOST="<XXXXXX>.stackhero-network.com"
export SERVICE_ID="<SERVICE_ID>"
export CERTIFICATES_PASSWORD="<CERTIFICATES_PASSWORD>"

cd /tmp/ \
  && curl -o certificates.tar https://docker:$CERTIFICATES_PASSWORD@$HOST/stackhero/docker/certificates.tar \
  && tar -xf certificates.tar \
  && (docker context rm -f $HOST 2> /dev/null || true) \
  && docker context create $HOST \
    --description "$SERVICE_ID ($HOST)" \
    --docker "host=tcp://$HOST:2376,ca=ca.pem,cert=cert.pem,key=key.pem")

This command creates a Docker context named after your service domain. You can see all available contexts with:

docker context ls

If you update your service domain, your certificates will change. You will need to reinstall them to reconnect securely.

By default, running docker ps shows containers on your local machine. For example, running:

docker run --rm alpine wget -q -O - ifconfig.me

returns your local public IP, since the container runs on your computer.

To work remotely, switch your Docker context to your Stackhero for Docker instance:

docker context use <XXXXXX>.stackhero-network.com

Now, every Docker CLI command executes on your remote Docker server. Running the same IP check command:

docker run --rm alpine wget -q -O - ifconfig.me

will show your Stackhero for Docker instance's public IP. This confirms your containers are running on the remote server.

To switch back to your local Docker daemon, just run:

docker context use default

When you mount a volume in a remote container, the files available are from the remote server, not your local machine. For example, docker run -it -v ${PWD}:/mnt alpine will mount the remote directory, not your current local directory.

Docker Compose also uses the current Docker context. Once you set your context to the remote instance with:

docker context use <XXXXXX>.stackhero-network.com

every Docker Compose command you run will operate on your remote server. This makes deploying multi-container applications as simple as working locally, but now on your production environment.

Switching contexts with docker context is useful for interactive use. For scripts or Makefiles, the DOCKER_CONTEXT environment variable gives you more control. You can find more details in our advanced documentation.

For a deeper look at Docker contexts, the official Docker documentation on contexts provides further guidance.