Skip to content

Docker

docker compose

docker compose  --env-file .env.dev config
docker compose  --env-file .env.dev up -d

Add your user to the docker group

Step 1: Run command > sudo usermod -aG docker $USER

Step 2: Logout from the machine

Step 3: Relogin and Run docker command without sudo

Working with docker running in remote machine

Pre-Condition: User should be added to docker group

Step 1: Add host in ~/.ssh/config

Host <SSH_HOST_ALIAS>
HostName <HOST_IP_OR_HOSTNAME>
User <LOGIN_USERNAME>
IdentityFile <PATH_TO_PRIVATE_KEY>
# Restrict authentication to the specified private key
IdentitiesOnly yes

Step 2: Create Docker contexts using those host aliases.

docker context create [dockercontextName] --docker "host=ssh://HostAlias"

Step 3: Test the connection

docker --context [dockercontextName] ps

Step 4: Switch to the context

docker context use [dockercontextName]

Step 5: To show current active context

docker context show