Using DDEv I'd like to be able to run the command ddev start and after starting it would automatically open the site in my browser. I know I can run ddev launch separately but I'd like it to happen automacically.
I tried chaining the commands but that failed and I also looked at the post-start hook but couldn't get it to work.
Is this possible?
(edited with full recipe)
Use a post start exec host hook that does ddev launch. Add this to your .ddev/config.yaml:
hooks:
post-start:
- exec-host: ddev launch
You don't have to run ddev launch after ddev start – just run ddev launch. If the container is not running yet, a ddev start will be executed automatically as well.
Related
I'm trying out laravel sail for a local project and I can't for the life of me find an easy way to exec into the container and tail my logs. I'm sick of googling and finding nothing-- does anyone have a link to docs or know the easiest way to accomplish normal devving with Laravel sail? I'm considering giving up this technique and doing it the normal Docker way.
Sail is just a way to configure your docker environment easily, you can still run every docker command as normal, or even publish the sail files and modify them for yourself (and then remove the package). To enter a container execute docker exec -it <container> bash or ./vendor/bin/sail shell or ./vendor/bin/sail root-shell. To tail logs of a container, you can run docker logs --follow <container>.
I've made a custom command to my ddev, creating a database backup with a single command (yes, I'm lazy, sorry).
I was thinking if there's some way to hook a ddev command, e.g. ddev poweroff to run another command or command sequence together.
The idea is to make a backup of all databases in a specific directory when I run the ddev poweroff.
Anyone have a clue about it?
Thanks
Sure, pre-stop exec-host hooks can invoke ddev directly. Here's an example of a pre-stop hook that does both a snapshot and a traditional db dump:
hooks:
pre-stop:
- exec-host: ddev snapshot --name=$(date +%Y%m%d%H%M)
- exec-host: mkdir -p .tarballs && ddev export-db --file=.tarballs/db.$(date +%Y%m%d%H%M).sql.gz
For more info on hooks, see DDEV hook docs.
Hope that helps!
Using the Docker App from the Marketplace, I can set a command to run on the Linode creation. What if I need to change the command like changing the image tag? Where can I find the info in Debian so I can edit it after creation?
After a few tests, I figured out that the command is not stored in the Linode and not run at reboot. Restarting a container at reboot is done by adding a restart policy in the Docker Run command.
In case I need to update the image with a newer version, I need to stop the current one and do a Docker Run with the new image.
I added a redis third-party service and tested it (see redis example.
Then I removed it. Now when I do a ddev start I see:
Found orphan containers (ddev-d8composer-redis) for this project. If you removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up.
I did a docker container prune and that seemed to fix it right up. It didn't appear to delete anything else and ddev restart stopped complaining right away.
This message is coming from docker-compose and ddev doesn't have direct access to it. You can fix it with ddev stop or ddev poweroff, both of which will find the orphaned Docker container and shut it down.
(Note that this has nothing to do with redis; you can get this same message with any DDEV third-party service.)
I'm working on a project using ddev and I don't know how to troubleshoot things because they're hidden in the containers they run in. For example, I've tried ddev logs but it doesn't give me enough information.
Use ddev list and ddev describe to get the general idea of what's going on, but then ddev logs is the first line of investigation. It gets the logs of the web container (both the nginx error log and the php-fpm error log, mixed together).
Extra approaches:
You could probably (temporarily) remove any custom nginx/php/mysql configuration that you might have added to the project in the .ddev folder, as those are common culprits.
Please make sure you're using the current docker images that match the ddev version you're using. I recommend deleting any "webimage" or "dbimage" lines in your .ddev/config.yaml.
ddev logs -f will "follow" the web logs, so you can see what happens when you hit a particular URL.
ddev logs -s db (or of course ddev logs -f -s db will show you the logs of the database container (MariaDB logs)
Use ddev ssh (for the web container) or ddev ssh -s db (for the db container) to actually go in there and look around. The most important logs are in /var/log/ and /var/log/nginx.
You can even use ddev logs when a container has crashed or stopped for some reason, and figure out what happened with it.
Don't forget the troubleshooting section in the docs.