Skip to main content

Docker compose CLI

    I was surfing on the internet but could not find a good tutorial on content which will help understand the usage of the docker compose cli commands. Now the question is if we have a docker desktop why should we learn cli commands ? It is because now that we are seeing a lot of left shifting of the responsibilities on the developers including DevOps. Hence we should know how to manage, debug and check the environment servers which may not have a docker desktop sort of GUI. Another question would be if we have docker cli commands then why should we learn the docker compose cli commands ? It is because docker cli commands are more general level and docker compose commands work at a docker compose level. Meaning a folder which has a docker-compose.yml file. The docker compose CLI commands are applicable for that scope. Another reason is it simplifies the services and container management at the compose level. One key point to be noted is we should remember the fact that docker compose containers and services (i.e. the ones defined in the docker-compose.yml file) run in an isolated scope hence service container A defined in docker compose yaml file A cannot directly interact with the service container B defined in the docker compose yaml file B.

    I will be documenting my learnings as step by step tutorial guide for you to understand and use the same. I will be doing so while I am learning these commands so that it is shared experience for a new person.

Comments

Popular posts from this blog

Secure login to MySQL for bash scripts

Introduction In this blog we will connect to a mysql via CLI from a bash script for generating a db dump. A cleaner approach for the same is using mysql config editor. In this blog we are taking an example of a mysql container running inside docker and we have a script for taking a db backup using  mysqldump . We will not use a password as a parameter to  mysqldump  command instead we will use something called as login path. MySQL config editor It is a utility to store authentication credentials in a obfuscated login path file named as  .mylogin.cnf . How to do it ? View existing configurations To view existing configurations if there are any use below command. The command will output existing configurations if there are otherwise it won't print anything. mysql_config_editor print --all Sample output In the output below you can see that the password is obfuscated and is not readable directly. It is handled by the mysql utilities to use this password as per the flags ...

Ruby on rails with Nexus

Introduction In this blog we will use nexus setup for NPM for a project which uses Ruby on rails. In this ruby on rails project we are using YARN and BUN  framework. We did setup a nexus NPM proxy and private repo but yarn could not fetch the npm dependencies via the nexus proxy. The rails assets precompile task however uses bun which uses npm. YARN is a wrapper on the NPM hence it does not entirely rely on NPM. BUN is a runtime which performs all the NPM tasks. Our goal in this blog is to understand how to handle this scenario in a ruby on rails project when use NEXUS NPM proxy. Technical specifications We have below versions of the tools NEXUS : 3.37.1-01 NPM : 9.5.0 NODE : v18.15.0 NVM : 0.39.1 ( Node version manager ) Mac OS : Sonoma 14.2 YARN : 3.5.1 BUN : 1.0.0 Steps Below are the steps required Configure NPM proxy in NEXUS Configure NPM private hosted repo Configure NPM group in NEXUS Change local NPM config for registry Change the YARN config for registry Configure BUN co...

Container detached from docker network

Introduction One fine day you find out that one of your docker containers is running but is not currently attached to the container network that you created using docker network command. Ideally a container should be detached from the network when there is some error in it. However, if you set the restart: on-failure in the docker-compose.yml  in that case the container should restart and still be attached to the network. In such a weird situation follow the steps documented in this blog. Possible reasons Listed below are the possible reasons for this issue Storage space issue Memory issue ( We will cover this in next blog ) Storage space issue We need to check the space utilisation at the server level first then drill down to the docker engine. Server level utilisation In most cases the server is ubuntu system hence check the disk usage using the disk free command (i.e. df -h ). It will show you the current storage space utilisation of the server. df -h Docker engine space utilis...