---
title: 'How to run Laravel Tinker in Docker, Sail, or Laradock'
description: 'Run Laravel Tinker in a Docker Compose, Sail, or Laradock container, then store the same container and app path in LaraBench.'
canonical_url: 'https://larabench.com/laravel-tinker-workflows/docker-sail-laradock'
md_url: 'https://larabench.com/laravel-tinker-workflows/docker-sail-laradock.md'
last_updated: '2026-07-28'
---
# How to run Laravel Tinker in Docker, Sail, or Laradock

> Run Laravel Tinker in a Docker Compose, Sail, or Laradock container, then store the same container and app path in LaraBench.

## Direct Answer

Find the container that can execute `php artisan`. For plain Docker Compose, use `docker compose exec app php artisan tinker`. For Sail, use `./vendor/bin/sail artisan tinker`. For Laradock, run Tinker from the workspace container, usually with `docker exec -it -w /var/www laradock-workspace-1 php artisan tinker`.

## When To Use This

Use this when the Laravel app only boots correctly inside a container, especially when `.env` points at Docker-only service names such as `mysql`, `redis`, or `mailpit`.

Before opening Tinker, identify the PHP container, the Laravel app path inside the container, and the container user if your app should not run as the default user.

## Terminal Approach

Start in the terminal. If these commands fail, LaraBench will fail for the same reason, because Docker connections run through `docker exec`.

### Plain Docker Compose

```bash
docker compose ps
docker compose exec app php artisan about
docker compose exec app php artisan tinker --execute="dump(config('app.name'));"
```

If the service starts outside the Laravel root, add the workdir:

```bash
docker compose exec -w /var/www/html app php artisan about
docker compose exec -w /var/www/html app php artisan tinker --execute="dump(config('app.name'));"
```

### Laravel Sail

```bash
./vendor/bin/sail artisan about
./vendor/bin/sail artisan tinker --execute="dump(config('app.name'));"
```

### Laradock

```bash
docker ps
docker exec -it -w /var/www laradock-workspace-1 php artisan about
docker exec -it -w /var/www laradock-workspace-1 php artisan tinker --execute="dump(config('app.name'));"
```

## LaraBench Approach

Open Connections, create a Docker exec connection, enter the container name, set the Laravel app path inside the container, set the environment label, add a container user only if needed, test the connection, then use it from Run Code.

LaraBench does not install a helper package inside the container. It needs Docker to be running locally, a reachable container, and a Laravel app root that can run Artisan.

## Safe Snippet

```php
return [
    'app' => config('app.name'),
    'environment' => app()->environment(),
    'database' => config('database.default'),
    'php' => PHP_VERSION,
    'base_path' => base_path(),
];
```

## Expected Result

A working run returns an array with the app name, environment, database connection name, PHP version, and app path. In LaraBench, the output appears in the result panel and the run is recorded in History with the selected connection.

## Troubleshooting

- `Could not open input file: artisan`: the workdir is wrong. Use the Laravel app path as it exists inside the container.
- `container not found`: run `docker ps` or `docker compose ps` and copy the running container or service name.
- Database host cannot resolve: run inside the app container, not on the host.
- Permission errors: match the user from your working terminal command, then set the optional LaraBench container user field.
- Tinker aliases or commands behave differently: check the app's `config/tinker.php` allow-list and alias settings.

## Safety Notes

Tinker runs real application code. A Docker connection can still point at staging or production services if the container environment does, so read the environment label before each run and begin with inspection snippets.

## Related Sources

- [Laravel Artisan Tinker documentation](https://laravel.com/docs/13.x/artisan#tinker)
- [Laravel Sail documentation](https://laravel.com/docs/13.x/sail)
- [Docker exec documentation](https://docs.docker.com/reference/cli/docker/container/exec/)
- [LaraBench Docker connections](https://larabench.com/docs/setup-guides/docker)
- [LaraBench Sail and Laradock setup](https://larabench.com/docs/setup-guides/sail-and-laradock)

## Related Workflows

- [Run Laravel Tinker over SSH](https://larabench.com/laravel-tinker-workflows/run-laravel-tinker-over-ssh)
- [Check Laravel production with a read-only Tinker snippet](https://larabench.com/laravel-tinker-workflows/safe-laravel-production-check)

## Canonical Page

- [HTML page](https://larabench.com/laravel-tinker-workflows/docker-sail-laradock)
- [Markdown mirror](https://larabench.com/laravel-tinker-workflows/docker-sail-laradock.md)

## Glossary

- [Laravel workflow glossary](https://larabench.com/docs/reference/glossary)

## Sitemap

See the full [sitemap](https://larabench.com/sitemap.md) for all public pages.
