Getting back ‘depends_on’ in docker-compose
Traditional enterprise apps are architected in a way that don’t always comply with the ‘perfect’ microservices architectures we expect to see with "Dockerized" apps. For example, Docker expects services to be stateless and self-configuring whereas traditional apps are often stateful and require external configuration after setup.
Being able to identify dependencies between containers and set a start-order is often required for complex systems to be migrated to Docker, however with the release of docker-compose v3, some of the features that helped make this possible are no longer available.
For example, many developers have used the depends_on configuration option in their docker-compose file to set a start-order but based on the Docker documentation (picture right), depends_on not only doesn’t wait for other services to start but it’s also been deprecated in docker-compose version 3.
In addition, alternative tags such as external_links or links are either not supported or are recommended against. Because of this challenge, our team put together a few features in Skopos to make setting the start-order during deployment or update possible.
Here’s how you can try this out:
Step 1: Run the Skopos container on your Docker host or swarm manager node
docker run -d -p 8100:8100 --restart=unless-stopped -e skstkn=dependsli --name skopos -v /var/run/docker.sock:/var/run/docker.sock opsani/skopos:edge
Step 2: Open your browser to http://localhost:8100 (if on a remote machine, replace “localhost” with the host name or IP address)
Step 3: Choose an option to get started…
- Discover Existing Applications — if you already have an application running, Skopos will scan your Docker registry and produce a visual of your architecture.
- Import a Docker Compose File — if you have an existing compose file you can import it to Skopos and Skopos will produce a visual of your architecture.
- Use Our Demo App — if you don’t want to try this on your existing system, you can pull our demo app from GitHub and use it to test out this feature.
Step 4: App List
Once your app(s) is(are) in Skopos, click on the app name to view the architecture.
Step 5: View the Application Architecture
The next screen shows you your application architecture. From here, you can edit the application to identify dependencies by clicking the “Edit” button at the top of the screen.
Step 6: Identify Start-Order
Drag the arrows to identify order in your app. Note that the items to start first are on the right. Example in the graphic below, I made NGINX dependent on the ‘vote’ container.
Click on the arrow to identify the connection strictness (Strict, Tolerant or Independent).
Save your changes and change to “Deploy” mode to deploy the changes.
7. View Your Deployment Plan and Start the Deployment
Click the “Switch to Plan” button to see the deployment plan before you start. You can drill in on each step to see the details and also view the automated rollback plan.
Click the Start button to begin your deployment. Skopos will deploy your application with all the dependencies you’ve identified.
8. Export your Compose File
You may want to export this application architecture as a Docker-compose file to save it to your source repository for future use. To do that, click the { } button, and select “Compose File”.
I hope you find value in this new feature to help you identify and deploy your application with start-order dependencies. Let me know in the comments below what else you’d like to see in Skopos.
If you’d like to learn more about Skopos, start here.