A dead simple way to run Tailwind CSS from a Docker container.
No more Node.JS. No more manual downloads of the CLI.
-
Create
input.cssin your project:@import 'tailwindcss';
-
Create
docker-compose.ymlin your project:services: tailwindcss: # You can also use pinned versions, e.g. `:4.1.7` image: ghcr.io/scriptogre/tailwindcss:latest tty: true # Required for watch mode volumes: - .:/app command: -i ./input.css -o ./output.css --watch
-
Or run
docker runcommand (note the-tflag is required for watch mode):
docker run -t -v "$(pwd)":/app \
ghcr.io/scriptogre/tailwindcss:latest -i ./input.css -o ./output.css --watch- For watch mode (
--watch), you must:- In
docker-compose.yml: Settty: true - In
docker run: Use the-tflag
- In
- Without these, the container will exit after the first build
- Make sure you mount all source files (
*.html,*.css,*.js, …) to/app, so Tailwind’s watcher can see them within the container. - The
ghcr.io/scriptogre/tailwindcss:latestimage is rebuilt daily to track the newest Tailwind CSS release.