DEV Community

Hanane Kacemi
Hanane Kacemi

Posted on

TIL: using --no-deps with docker compose

Currently, I am working on a Laravel project with two containers: one for the web app and the other for the database.

Previously, whenever I needed to update the image used by the container hosting the web app, I had to stop both containers using docker compose stop app db, remove them with docker compose rm -v app db, execute docker compose down, and finally rebuild to apply changes to the desired container using docker compose up --build -d

As you might guess, this process required me to export the database, even if I only wanted to apply changes to the app container.

Recently, while watching some tutorials related to Docker and Docker Compose, I learned about the --no-deps option. This option allows us to apply changes to one container without affecting the other dependent containers.

Now, whenever I want to recreate the app container using a new image, I simply run:

docker compose stop app
docker rm app
docker compose up -d --no-deps app

There's no need to export the database, remove the database container, or import it again. This process is much easier for me now.

Thanks for reading!

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay