Skip to content

Instantly share code, notes, and snippets.

@harsh4870
Created November 3, 2023 13:59
Show Gist options
  • Save harsh4870/5dfbc28b3358c90d33b73d32e028bcc1 to your computer and use it in GitHub Desktop.
Save harsh4870/5dfbc28b3358c90d33b73d32e028bcc1 to your computer and use it in GitHub Desktop.
Docker compose basic Ubuntu & Nginx
version: "3"
services:
ubuntu:
container_name: ubuntu
image: ubuntu
restart: on-failure
command: ["sleep","infinity"]
ports:
- '6379:80'
nginx:
container_name: nginx
image: nginx
ports:
- '8080:80'
@harsh4870
Copy link
Author

Save file with same name and run the below commands,

docker-compose up

Make sure file should exist in same dir where running command

Check container status

docker ps

If Ubuntu & Nginx container running

Go inside the Ubuntu Container

docker exec -it ubuntu bash

Now you are inside the container update the packages

apt update && apt install curl

Let's now try connecting to Nginx

curl nginx

You can install other module as per requirement on Ubuntu container (Consider it like PC) and from any other container you can connect to it by service name. .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment