Introduction
Shard Cloud doesn’t rundocker-compose.yml files directly: each application runs one container. A Compose project moves by splitting it into its parts: each service becomes a managed application or database. Most of those parts get simpler on the way, since Shard Cloud manages the databases, HTTPS, restarts, backups and metrics for you, with no server to maintain.
How Compose Maps to Shard Cloud
Before You Start
What you need
- The project, with its
docker-compose.yml, running somewhere you can reach (your computer or the current server), to copy the data - A Shard Cloud account with room for every service and database (see the minimum RAM of each on the limits page). Custom Docker images need the Core plan or above
- Docker on your computer, to restore the databases
Classify each service
Opendocker-compose.yml and put each service in one of these groups:
Step 1: Create the Databases and Move the Data
Create each database
image: tag or a newer one (postgres:16 → PostgreSQL 17 or 18 is fine). The version can’t change later. Copy each database’s connection URL from its page.Dump the data from the Compose project
db is the service name; -T keeps the output binary-safe):- PostgreSQL
- MySQL
- MongoDB
environment: (POSTGRES_USER, POSTGRES_DB, MYSQL_ROOT_PASSWORD, MONGO_INITDB_ROOT_USERNAME…). If the project runs on a server, run this there and copy the file to your computer.Restore it into Shard Cloud
- PostgreSQL
- MySQL
- MongoDB
postgres:17, postgres:18):Step 2: Move Your Code
If a service runs your own code in a supported language, you usually don’t need its Dockerfile at all: Shard Cloud’s language containers install your dependencies (package.json, requirements.txt, go.mod…) and start the app. Translate the service into a .shardcloud file:
api folder:
- Port: the app must listen on port 80, on
0.0.0.0. Every language container setsPORT=80, so an app that readsPORTneeds no change; one hardcoded to 3000 must be changed. - Build steps from the Dockerfile (
RUN npm run build,RUN python manage.py collectstatic) go in front of the start command:CUSTOM_COMMAND=npm run build && npm start. - System packages from the Dockerfile (
apt-get install): the language containers already include common ones (ffmpeg, Chromium’s libraries, image libraries, the PostgreSQL client). If you need others, use a custom Docker image (step 3). - Python: run tools as modules (
python -m gunicorn,python -m uvicorn main:app --host 0.0.0.0 --port 80), since installed scripts aren’t on thePATH.
node_modules/, virtualenvs or build output, with .shardcloud at the root, and upload it in the Dashboard. See your language’s guide under Languages for details.
Step 3: Services That Need Their Own Dockerfile
Upload the service’s build context as a custom Docker image, then create an application from it. Shard Cloud builds your Dockerfile as it is, but the container runs with a few rules that a Compose setup doesn’t have. Check your Dockerfile against each one:Put the Dockerfile at the root of the ZIP
build: context: points at, with the Dockerfile at the root of the ZIP and named Dockerfile. If Compose uses dockerfile: docker/api.Dockerfile, copy that file to the root as Dockerfile. build: args: don’t exist here: write them as ARG NAME=value defaults in the Dockerfile. The ZIP can be 100 MB at most, and a build can take 15 minutes at most.Don't put your code in /app
/app (and at /tmp). It starts empty and hides anything the image had there, so an image that copies its code to /app starts with an empty folder. Use another folder for the code, and keep /app for the files that must survive restarts (uploads, SQLite, sessions):Listen on port 80, and run as root
PORT is not set for you in a custom image: set it in the Dockerfile if your app reads it (ENV PORT=80). The server must listen on 0.0.0.0.The container can only open port 80 as root, and it can’t switch users after starting. Remove USER lines (USER node, USER 1000), and don’t use entrypoints that drop privileges with gosu or su-exec. The container still runs isolated, with most root powers removed.nginx inside the image
nginx.conf (replacing its user line), and listen 80:Secrets at runtime, not at build
ARGs or files copied into the image.ENTRYPOINT/CMD: there is no start command to change per application. For a worker that shares the image with the web app, either build a second image with its own CMD, or let one image start either role from an environment variable:ROLE=worker on the worker application.Step 4: Rewire the Environment Variables
In Compose, services find each other by service name. Those names don’t exist on Shard Cloud, so for each application, write its variables in a.env file and replace:
ssl: { rejectUnauthorized: false } in Node’s pg, or sslmode=require).
Step 5: Replace the Reverse Proxy
In most Compose projects, nginx, Traefik or Caddy is there for HTTPS and to send each domain or path to the right service. On Shard Cloud:-
HTTPS is automatic for every application, on its
*.shardweb.appaddress and on your own domains. -
One domain per service is the simplest setup:
example.comon the frontend app,api.example.comon the API app. Point the frontend at the API’s address, and allow it in the API’s CORS settings. -
Paths on one domain (
/→ frontend,/api→ API): serve the frontend from the API app (many frameworks can serve static files), or keep a small nginx application that forwards to the other apps’ public addresses:Build it as a custom image fromdefault.confnginxwith theuser root;andmaster_process off;lines from step 3.
Step 6: Deploy and Test
Create each application
.shardcloud for regular applications, or an application from its custom image. Give a SUBDOMAIN only to the services that receive web traffic (they need at least 512 MB); workers need none (256 MB).Import the environment variables
Copy persistent files
docker compose cp api:/data ./data) and upload them to the application’s /app folder with the file manager in the dashboard.Test, then move your domain
*.shardweb.app address, then add your domains and point their DNS at Shard Cloud. See Custom Domain. Keep the old project and its volumes until you’ve checked the data.Deploy on every push (optional)
.shardcloud file committed to the repository applies to every application deployed from it: with several services in one repository, keep .shardcloud out of git and let each application keep its own.Troubleshooting
Custom image: Cannot find module '/app/...' (or the code folder is empty)
Custom image: Cannot find module '/app/...' (or the code folder is empty)
/app hides what the image put there. Move the code to another folder (WORKDIR /srv/app) and rebuild. See step 3.Custom image: permission denied when binding port 80 (EACCES)
Custom image: permission denied when binding port 80 (EACCES)
USER line so the server runs as root.nginx: setgid(101) failed (1: Operation not permitted)
nginx: setgid(101) failed (1: Operation not permitted)
user root; and master_process off; to nginx.conf.gosu / su-exec: operation not permitted
gosu / su-exec: operation not permitted
getaddrinfo ENOTFOUND db (or redis, api...)
getaddrinfo ENOTFOUND db (or redis, api...)
The app starts but the site doesn't load
The app starts but the site doesn't load
0.0.0.0, not on another port or on localhost only. In a custom image, PORT isn’t set for you: set ENV PORT=80 if the app reads it.The image build fails or times out
The image build fails or times out
.dockerignore for node_modules, .git and build output.Changed an environment variable and nothing happened
Changed an environment variable and nothing happened