Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

skiarsi's avatar

change DB_HOST, DB_PORT, DB_USERNAME, DB_DATABASE from bitnami/laravel docker

Hi everyone.

I ran a laravel project with bitnami/laravel docker :

docker run -d --name laravel-001 -p 8000:8000 --env DB_HOST=mariadb-001 --env DB_PORT=3306 --env DB_USERNAME=user --env LARAVEL_DATABASE_PASSWORD=password --env DB_DATABASE=database --network laravel-network --volume ${PWD}/projects/laravel:/app bitnami/laravel:latest

But now I need to change DB_HOST and other database configurations. I did changes from .env and clear catche and restart container but not any changes. and I don't have any access into docker image and docker compose.

if you have any solution for it, please tell me. thanks. have a good year

0 likes
2 replies
Ali497779's avatar

First You Need to Stop the Docker and on changing the .env won't update the container also

Run these commands: docker stop laravel-001 docker rm laravel-001

Then recreate the container with updated environment Run this:

docker run -d --name laravel-001 -p 8000:8000
--env DB_HOST=new_host
--env DB_PORT=new_port
--env DB_USERNAME=new_user
--env LARAVEL_DATABASE_PASSWORD=new_password
--env DB_DATABASE=new_database
--network laravel-network
--volume ${PWD}/projects/laravel:/app
bitnami/laravel:latest

check the .env file in the project directory

Run php artisan config:clear and php artisan cache:clear inside the container.

1 like
skiarsi's avatar
skiarsi
OP
Best Answer
Level 3

OK.

I thought if I remove a docker image, all project will remove, but it's not like that. I just stop and remove last docker image, and run new docker image with new env data and everything goes well and it was becuses of --volume that was same as prev image.

It could be good if Laravel have own containers in hub.docker.com

Please or to participate in this conversation.