python-ship

A cross-platform Docker development environment and portable production
release builder for Python web apps. Ship supports Django, FastAPI, Flask,
and plain ASGI or WSGI apps, with Uvicorn, Hypercorn, Gunicorn, and Granian.
Community packages can add frameworks, servers, or services.
Python Ship and PHP Ship share
the same CLI workflow, ship.json vocabulary, and portable release format.
Contents
- Why not just write a Compose file?
- Requirements
- Quick start
- Upgrading the project layout
- Choosing services
- Commands
- Image build output
- Running setup commands before startup
- Services
- Broadcasting
- Web servers and app entry points
- Browser testing
- Configuration (
ship.json)
- Adding a service later
- Multiple instances of a service
- Custom service names and an external network
- Dependencies and
ship uv
- Background tasks (Celery)
- Production releases
- HTTPS / TLS
- Backing up data volumes
- Frontend dev server (Vite HMR)
- File ownership in dev
- Debugging (debugpy)
- Faster file sync on Windows/macOS (Mutagen)
- Running more than one project at once
- Customizing the stack
- Extending ship
- Architecture
- Contributing
- License
Why not just write a Compose file?
You can, and every project that uses Ship ends up with one — Ship generates
it. What Ship adds is everything around that file that each project would
otherwise rebuild by hand:
- One cross-platform CLI.
ship is a Python executable, so ship up,
ship exec and ship db run natively on Windows, macOS and Linux, with no
shell scripts and no requirement to keep the project inside WSL.
- A portable release artifact, not just a dev tool.
ship release --tag
builds real production images (no bind mount, no uv or pip, a non-root
user) from the same ship.json and packages them with a final Compose
file, .env.production, and a deploy script into dist/ship/<tag>/. The
server needs nothing but Docker — see
Production releases.
- A real database shell without a published port.
ship db opens
the database client inside the database container, reading its credentials from
that container's own environment.
- Not tied to a framework. The core knows nothing about Django or
FastAPI; both are
FrameworkAdapter
implementations on the same public extension point a third party uses —
the Starlette example
is one. A plain ASGI callable needs no framework, requirements.txt or
pyproject.toml at all.
- Postgres and MySQL, Redis, RabbitMQ and Celery, four S3-compatible
stores, Meilisearch, Mailpit, Selenium and Playwright, Node; Uvicorn,
Hypercorn, Gunicorn and Granian —
ship init picks one option per group;
nothing is hardcoded to one choice.
Requirements
- Python 3.11+ to run the
ship CLI itself — or just
uv, which
installs ship with a Python it manages.
- Docker Desktop (or Docker Engine with Compose v2). This is what actually
runs your project;
ship drives docker compose.
- uv on the host.
ship init offers to install
it with Astral's official installer if it's missing, and makes no changes to
the project if you decline.
- An ASGI or WSGI app. Nothing else: no framework, no dependency manifest, no local
database, no Node install.
Quick start
uv tool install python-ship
cd your-project
ship init
ship up
Open the URL printed by ship up, normally http://127.0.0.1:8000. Run
ship manage migrate if a Django project needs migrations, and ship down
when you finish.
ship init detects Django, FastAPI and Flask, including Flask app factories,
then suggests an import target and compatible web server. To start from an
empty directory, use a plain ASGI or WSGI example.
You can install the CLI with pipx install python-ship, or add it to a uv
project with uv add --dev python-ship and run commands as uv run ship ....
Commit ship.json, the published files under docker/ship/, the project-root
ship launcher, and .env.example. Use the installed CLI or run the launcher
as ./ship on Linux and macOS or python ship on Windows.
For scripts and CI, use --no-interaction (-n) with explicit choices.
ship init -n --framework django --app project.asgi:application \
--server hypercorn --database postgres --cache redis
Upgrading the project layout
Run ship init after updating Python Ship. It publishes the current layout in
docker/ship/ and archives an older managed ship/ directory in
docker/ship-legacy/ to make room for the launcher. Review customizations and
update paths in your Compose override. See the
upgrade guide for Dockerfile and data migrations.
Choosing services
The wizard asks for the project name, framework and app target, then offers
servers compatible with the app's interface. Select the kinds of service you
need, then choose one provider per selected kind. Each provider list ends with
None. The wizard offers named instances
for eligible services in a separate step.
Ship also asks about Python, Compose service names, production processes,
external networks, and the host ports to publish in each environment. New
projects start with Python 3.14 and the app's HTTP port published in both
development and production. Review the summary before writing changes. In the
terminal wizard, press Ctrl+U to return to the previous prompt.
After confirmation, the wizard shows a table for each environment file with
its values, the service or group that uses each key, and what changed.
Credentials appear masked.
| File |
What Ship fills in |
.env |
Development defaults, managed connection settings such as DB_HOST, and selected host ports. If the file is missing, Ship starts with .env.example when available. |
.env.example |
Known connection defaults and blank placeholders for credentials and custom values. |
.env.production |
Production connection settings and placeholders for required credentials. Ship omits settings used only by development tools. |
Ship preserves configurable credentials and suggests the Python client
packages your selected services need. Add them to your application
dependencies and rebuild with ship up. Use Production releases
when you are ready to build a deployment.
Commands
Run ship --help for the grouped command list or ship help <command> for
options and examples.
| Command |
What it does |
ship init |
Picks the framework, app target, server, services and published ports. Writes ship.json, the project launcher, and Docker templates under docker/ship/. Run ship init --help for automation flags. |
ship up |
Regenerates docker/ship/docker-compose.generated.yml from ship.json, builds the development images, then starts the stack and waits for container healthchecks and an HTTP response. |
ship build |
Builds every project-owned production image, tagged locally. Needs .env.production as soon as a selected service has a required credential. See Production releases. |
ship release --tag <tag> [--force] [--no-env] |
Builds the same images (re-tagged) and assembles the portable release under dist/ship/<tag>/. |
ship down [--volumes] |
docker compose down. --volumes also deletes named volumes (database and storage data — use with care). |
ship ps [OPTIONS] [SERVICE...] |
Shows development containers, including stopped ones, and their published ports. Passes filters and formatting options to Compose. |
ship run [--env NAME=value] [--] COMMAND [ARGS...] |
Runs a setup command in a disposable development container with the project bind-mounted. Works before ship up. |
ship exec <service> <cmd...> |
Runs a command inside a running service. The generic escape hatch every shortcut below wraps. |
ship shell [service] |
Opens a shell (sh) in a service; defaults to the app. |
ship logs [service] [-f] |
Shows logs for one service, or all of them. -f/--follow streams. |
ship db [instance] |
Opens the database's client (psql/mysql/mariadb/mongosh/sqlcmd) with credentials from its own container. Name one of additionalServices' databases to open that instance instead. |
ship check |
Validates ship.json, published files, both Compose models, and required production settings without Docker. Groups errors and warnings. ship config:test is an alias. |
ship doctor |
Shows project and runtime versions, published templates, and a color-coded table of development service states, health, images, and ports. Lists problems with recovery commands. |
ship uv <args...> |
Runs uv dependency commands (add, remove, lock, tree, ...) in a temporary container with the project's Python. See Dependencies. |
ship npm/pnpm/yarn <args...> |
Runs the selected, exactly pinned tool in the Node frontend service. The manifest and lockfile remain authoritative. |
ship package-manager TOOL[@VERSION] [--yes] |
Switches the frontend tool, records the pin and reinstalls. Uses a disposable Node container before the stack starts. Restores recorded files and dependencies after installation failure. |
ship test [-- ARGS...] |
Runs Cypress on demand, or Python pytest against the selected Selenium/Playwright service. Install/configure the application's test client first. |
ship manage <args...> |
Runs python manage.py in the app — only registered for Django projects. |
ship flask <args...> |
Runs the flask CLI in the app (FLASK_APP is set) — only registered for Flask projects. A community adapter registers its own commands the same way. |
ship --version |
Shows the installed python-ship version. |
ship help [COMMAND] |
Lists commands by workflow or shows help for one command. |
Every proxied command forwards its arguments exactly as typed (including
flags such as ship manage migrate --database=other), and returns the inner
command's exit code. --project-directory PATH before any command runs it
against another project. Without a terminal (CI, piped input), exec-style
commands pass -T to Compose, so ship db < dump.sql works.
Image build output
Ship shows a spinner and the latest Docker build step on a dimmed line below
it. CI and non-interactive sessions show a plain progress line. Docker still
uses its build cache.
Successful build logs are hidden by default. A failed build prints Docker's
diagnostics and returns Docker's exit code.
Once the build finishes, ship up shows Compose's container startup progress.
The same build display applies to production build and release, and to
ship test when it builds the Cypress image. Test output streams live.
To stream the full build log, put -v or --verbose before the command:
ship -v up
ship -v build
Running setup commands before startup
After ship init, use ship run for commands that need your development
Python or Node environment. The temporary container mounts the project, so
files it writes there persist. Ship passes through command output and exit
status, and removes the container when the command exits. It starts without
dependent services or published ports. Run migrations and other commands
that need the database after ship up.
ship run python --version
ship run --env DJANGO_SETTINGS_MODULE=project.settings -- python manage.py check
ship run npm ci # with the Node service selected and a package-lock.json
ship up
Frontend setup commands such as ship npm ci can also use a disposable Node
container when the frontend service is stopped.
Services
ship init selects one provider per group. Use
additionalServices for extra named
instances of supported providers. Ship creates containers, adds health checks
where available, and supplies connection settings. Your app declares its
client dependencies and connects using those settings.
Databases (database)