How can I run a simple Debian container using Docker stack?

0
5
Asked By CuriousCoder93 On

Hey everyone! I'm having some trouble getting a basic container up and running using a Debian image for my Docker stack. Here's what my `docker-compose.yml` file looks like:

```
version: '3.7'
services:
es01:
image: debian:latest
container_name: debian
deploy:
replicas: 1

networks:
debian_default:
driver: overlay
```

When I try to deploy this stack with the command `docker stack deploy -c debian.yml debian`, I run into an issue where it shows 0 replicas running. What do I need to do to resolve this?

2 Answers

Answered By TechWiz2021 On

To keep your Debian container running, you should specify a command for it to execute. You can add something like `command: ['sleep', 'infinity']` in your service definition. That way, the container doesn't exit immediately after starting. Here’s how your config should look:

```
version: '3.7'
services:
es01:
image: debian:latest
container_name: debian
command: 'sleep infinity'
deploy:
replicas: 1

networks:
debian_default:
driver: overlay
```

Answered By CloudyDev78 On

Make sure you're starting a process in the container (like the sleep command mentioned earlier). Without a running process (PID 1), Docker thinks the container has stopped. You want to keep it alive to ensure it functions properly.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.