Containers doesn't start after doing docker-compose up -d

Viewed 65

i'm having some problems using dockers.

First of all, i did a docker-compose.yml:

version:  "3.9"

services:
   web:
    build: .
    ports:
     - 8000:80
    volumes:
     - $HOME/sitios:/var/www/html
   db:
    build: .
    ports:
     - 3000:3306
    volumes:
     - $HOME/"mariadb copia":/var/lib

As you can see here, i want to make a docker with two volumes, one with HTTP and other with mariadb server. Here is my Dockerfile:

FROM ubuntu:latest
RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get install nano mariadb-server apache2 -y

Then, i use the command sudo docker-compose up -d, however, the docker doesn't start at all, i try sudo docker start <name> but it doesn't work.

I already googled and i already looked into the official docker documentation but i can't find anything.

Thanks for your help.

1 Answers

Because you're using ubuntu:latest you're missing an entrypoint.

So it starts but immediately exits with exit 0.

Another thing: do not do apt upgrade inside the dockerfile, just take another Image (with a higher version or whatever you looking for).

One more thing: you use two different services, in the same image, it's pretty weird.

And one last thing: use the official Images, so you do not have to build them yourself.

Related