user7341673
user7341673

Reputation:

Docker ubuntu image is not working

I am trying to create a docker container from docker image but it is not starting and I don't see error. First I tried this Docker file:

FROM php:7.0-apache
MAINTAINER Tony Lea <tony.lea@thecontrolgroup.com>

EXPOSE 80

RUN docker-php-ext-install pdo pdo_mysql mysqli

RUN apt-get update && \
    apt-get install -qqy \
      libmcrypt-dev \
      git-core \
      zlib1g-dev && \
    docker-php-ext-install \
      bcmath \
      mbstring \
      mcrypt \
      zip

WORKDIR /var/www/html

ENV COMPOSER_HOME=/var/www/html

RUN curl -sS https://getcomposer.org/installer | php && \
    mv composer.phar /usr/local/bin/composer

And inside docker compose I used this code:

version: '3'
services:
db:
  image: mysql
  restart: always
  environment:
    MYSQL_ROOT_PASSWORD: password

  volumes:
    - ./mydata:/var/lib/postgresql/data
  ports:
    - "52000:3306"
web:
  build: .
  volumes:
    - .:/var/www/html
  ports:
    - "3000:80"

First time I run this it worked and I stopped container and removed them and when I am trying docker-compose up I don't see any error and mysql container is running but ubuntu container is created but it is not running when I try to start I don't see error.

I tried to create one container using docker run ubuntu:18.04 it is creating a container but it is not starting I don't know what just happened. When I run docker ps -a I see this:

CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                      PORTS                     NAMES
eae0840f282a        ubuntu:18.04        "/bin/bash"              16 seconds ago      Exited (0) 14 seconds ago                             priceless_haibt
4689e8787905        ubuntu:18.04        "/bin/bash"              25 seconds ago      Exited (0) 23 seconds ago                             sad_williams
1284e06b22a8        mysql               "docker-entrypoint.s…"   12 minutes ago      Up 3 minutes                0.0.0.0:52000->3306/tcp   kyolab_db_1
7db2c0c987cd        kyolab_web          "/bin/bash"              12 minutes ago      Exited (0) 2 minutes ago                              kyolab_web_1

I tried this docker run -d -p 3000:80 --name=nilay ubuntu but no luck

What should I do ??

Upvotes: 0

Views: 8667

Answers (1)

tripleee
tripleee

Reputation: 189830

Your image runs /bin/bash, then exits. You need to specify in the docker run a command to run, or add a CMD default command to your Dockerfile.

If you want to run an interactive shell, you can't use -d, and need -it instead.

Upvotes: 5

Related Questions