Docker Run to Compose API
Convert one or more docker run commands into a docker-compose.yml: ports, volumes, env vars, networks, restart policy, healthchecks, resource limits and more. Unsupported flags come back as warnings.
POST /api/v1/tools/docker-run-to-composeMCP docker_run_to_composeDeveloper ToolsConvert docker run commands into a docker compose YAML file. Ports, volumes, env vars, networks, health checks, limits and logging are mapped for you.
Input
Send these as a JSON object. Unknown fields are rejected.
- command
- One or more docker run commands, separated by new lines, ; or &&. Line continuations (\) are fine. (string, up to 100000 characters, required)
- resources
- How to write --memory/--cpus: deploy (deploy.resources.limits) or legacy (mem_limit and cpus). (string, one of deploy, legacy, default "deploy")
- containerName
- Add container_name when --name is given. (boolean, default true)
curl https://pithlab.com/api/v1/tools/docker-run-to-compose \n -H "Authorization: Bearer $PITHLAB_KEY" \n -H "Content-Type: application/json" \n -d '{"command":"docker run -d --name web -p 8080:80 -e NGINX_HOST=example.com -v ./html:/usr/share/nginx/html:ro --restart unless-stopped nginx:1.27"}'Example response
{
"ok": true,
"result": {
"output": "services:\n web:\n image: nginx:1.27\n restart: unless-stopped\n ports:\n - \"8080:80\"\n environment:\n NGINX_HOST: example.com\n volumes:\n - ./html:/usr/share/nginx/html:ro\n",
"services": [
"web"
],
"warnings": []
}
}