1

I have the following docker-compose file. When I try to up the file the mysql container start, but the php one keeps on restarting. When I look at the logs all I get is "interactive shell" constantly. Any idea why this is happening?

---
version: "3"
services:
  web:
    image: php:alpine3.12
    restart: unless-stopped
    volumes:
      - web_Data:/var/www/html
    ports:
      - 80:80
      - 443:443
    
  mariadb:
    image: mariadb
    restart: unless-stopped
    environment:
      MYSQL_ROOT_PASSWORD: Password1
    volumes:
      - mariadb_Data:/var/lib/mysql
    ports:
      - 3306:3306
volumes:
  web_Data:
  mariadb_Data:
    driver: local
2
  • Can you paste the logs of web service, please? Commented Jan 3, 2021 at 23:02
  • All I keep getting is exactly what I put on the description "Interactive Shell" constantly in detached mode. without the -d I get "exited with code 0" on line 1, then "Interactive shell" on line2 and the cycle repeats. Commented Jan 3, 2021 at 23:17

2 Answers 2

5

The reason you are getting Interactive shell message it's because that's an output of php:alpine3.12 image and since your container is constantly restarting, it keeps logging that message.

I don't really know PHP but it looks like the command that the image tries to do is docker-php-entrypoint php -a, and that starts an interactive shell, am I right?

If that is the case, then you need to run it in interactive mode. To do that, in docker-compose.yml file, just add the last 2 lines:

web:
    image: php:alpine3.12
    restart: unless-stopped
    volumes:
      - web_Data:/var/www/html
    ports:
      - 80:80
      - 443:443
    stdin_open: true
    tty: true       

Then your container will keep running and you will be able to interact with it.

Sign up to request clarification or add additional context in comments.

2 Comments

That worked. When I put the two lines. The server is now running. Thanks,
Great! Glad to help. I would appreciate if you accept the answer :)
1

The reason is that you are using an inappropriate PHP image. If you want to run PHP with a web server then you should use one of:

  • php:<version>-fpm
  • php:<version>-apache

See Image Variants in the Docker documentation.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.