Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Recommend way to Artisan on Docker

I am yet to find an elegant and efficient way to run Laravel Artisan commands in my Docker based local dev environment.

Could anybody suggest the recommended or "proper" way to do things like migrations?

Or, has anybody found a neat way of doing this? Ideally with examples or suggestions.

Things that I've considered:

  • A new container (sharing the same volume and db link) with ssh, just for running commands (seems nasty).
  • Hacks in supervisor that could then end up running on live (not ideal).
  • Editing db configs, or trying to hack in a "host" environment, so that at least things like migrate can be run from the host.
  • Creating web front ends to run things (really nasty).
  • Trying to build a "signal" for it things.

I'm still getting my head around Docker and it's new-container-for-everything approach.

I suppose I want to balance cool-dev-ops stuff with why-do-I-need-another-fake-server-just-get-it-working-already.

I'd love to commit to it for my dev workflow, but it seems to become awkward to use under certain circumstances, like this one...

Any suggestions and ideas are welcome. Thanks all.

like image 353
tomsowerby Avatar asked Jul 18 '14 09:07

tomsowerby


People also ask

Is Docker good for production?

Docker was created by developers and for developers. It provides environment stability: a container on the development machine will work exactly the same on staging, production, or any other environment. This eliminates the problem of various program versioning in different environments.

Why should I Dockerize my application?

As Docker reduces the need for more infrastructure resources for development and the container created for individual processes can be shared with other apps with instances of these containerized apps using less memory compared to virtual machines – it makes the development and deployment process more cost-effective.


1 Answers

Docker 1.3 bring new command exec So now you can "enter" running container like

docker exec -it my-container-name /bin/bash

After that you can run any command you want

php artisan --version
like image 56
terbooter Avatar answered Sep 18 '22 13:09

terbooter