0

I tried to create my own container based on Ubuntu (and the same with Debian). I use docker-compose to manage my containers and I use dockerfile to create my container.

When I use the docker-compose to create and start my container, I always had a status Exited 0 (without information in logs or on my screen and when I create and start with a simple docker command, it works well.

Do you have an idea why ?

My dockerfile

ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get -y update
RUN apt-get -y upgrade
RUN apt-get install -y sqlite3 libsqlite3-dev apache2 php php-sqlite3
RUN /usr/bin/sqlite3 /etc/apache2/db/test.db
RUN apt-get clean autoclean
RUN apt-get autoremove --yes
RUN rm -rf /var/lib/apt/lists/*
CMD /bin/bash

My docker-compose

bdd:
container_name: bdd
build: /docker/bdd
image: image_bdd:latest
kenlukas
  • 2,886
  • 2
  • 14
  • 25
weado
  • 1
  • What are the exact commands you're running with those files to get the results you describe. – GregL Nov 27 '19 at 12:17

3 Answers3

0

FROM directive is missing in the Dockerfile

Chaoxiang N
  • 1,218
  • 4
  • 10
0

You need to specify from what image do you want to work.

Try to modify the Dockerfile like these:

FROM ubuntu:latest

RUN apt-get -y update && \
    apt-get -y upgrade && \
    apt-get install -y sqlite3 libsqlite3-dev apache2 php php-sqlite3 && \
    /usr/bin/sqlite3 /etc/apache2/db/test.db && \
    apt-get clean autoclean && \
    apt-get autoremove --yes && \
    rm -rf /var/lib/apt/lists/*

ENV DEBIAN_FRONTEND=noninteractive

CMD ["/bin/bash"]

The docker-compose file needs to be like these:

version: '3'
services:
  bdd:
    build: /docker/bdd/
ginerama
  • 216
  • 1
  • 7
0

Thank for you answers. I forgot to put it in my question, but the line FROM ubuntu:latest was present. To answer, I found the solution with the CMD line, because you can find a lot of version on the internet :

CMD ["/usr/sbin/apache2ctl", "-DFOREGROUND"]

The line CMD ["/bin/bash"] didn't work well. Do you have some ideas why ?

weado
  • 1