Docker: Getting started
Fast, secure remote Docker management with Stackhero for Docker
Welcome to the Stackhero documentation
Stackhero offers 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 upcommand. No additional configuration is required: simply start your containers.- Choose your own domain name, automatically secured with HTTPS (for example: https://api.your-company.com, https://www.your-company.com, or https://backoffice.your-company.com).
- Benefit from high performance and enhanced security on private, dedicated infrastructure.
- Apply updates with a single click for straightforward, effortless maintenance.
Your containers can be live in production in around five minutes. Stackhero manages the infrastructure, updates, and security for you, so you can focus on developing your applications. Find out more about Docker CaaS cloud hosting.
How to use Docker CLI remotely
Docker CLI must be installed on your computer. If you have not already done so, you can download it from the official Docker website: Docker Desktop.
With Stackhero for Docker, you can manage your containers remotely using the Docker CLI, exactly as you would locally. This allows you to maintain your usual workflow, while executing commands directly on your production-ready Docker server, securely and efficiently.
Docker "contexts" make this possible. Contexts allow you to specify to the Docker CLI where your commands should be sent: either to your local Docker daemon or to your Stackhero for Docker instance. Switching contexts is quick and seamless.
Install Docker certificates
To connect securely to your Stackhero for Docker instance, you need to install its certificates on your computer. These certificates ensure authentication and encryption, keeping your connection private and secure.
You can use the following command to download and install 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 set in your Docker configuration on the 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 list all available contexts with:
docker context ls
If you change your service domain, your certificates will be renewed. You will need to reinstall them to reconnect securely.
Run Docker containers remotely
By default, the docker ps command shows containers running on your local machine. For example, running:
docker run --rm alpine wget -q -O - ifconfig.me
will display your local public IP address, since the container is running on your computer.
To work remotely, switch the Docker context to your Stackhero for Docker instance:
docker context use <XXXXXX>.stackhero-network.com
From now on, every Docker CLI command will execute on your remote Docker server. Running the same IP check command:
docker run --rm alpine wget -q -O - ifconfig.me
will display your Stackhero for Docker instance's public IP address. This confirms your containers are running on the remote server.
To switch back to your local Docker daemon, simply 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 alpinewill mount the remote directory, not your current local directory.
Deploy with Docker Compose
Docker Compose also uses the active Docker context. Once you have set the 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 allows you to deploy multi-container applications just as easily as you would locally, but directly on your production environment.
Switching contexts with
docker contextis convenient for interactive use. For scripts or Makefiles, theDOCKER_CONTEXTenvironment variable gives you additional control. You can find more details in our advanced documentation.
For a more in-depth look at Docker contexts, the official Docker documentation on contexts provides further information.