Docker Community Forums

Share and learn in the Docker community.

Node container always restart before launch compose

Hello!

I dont understand when i launch this compose the node container is always restarting.
Can you help me?

This is the compose file:

version: '3.7'
services:
  mysql:
    image: mysql:5.7
    container_name: mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: pass
      # MYSQL_DATABASE: db
    ports:
      - 3306:3306
    volumes:
      - /home/carlos/Escritorio/volumenes/mysql:/var/lib/mysql
    networks:
      laravel_net:
        ipv4_address: 172.21.100.10
  web:
    # image: php:7.4.16-apache-buster
    restart: always
    container_name: laravel
    build:
      context: .
      dockerfile: ./Dockerfilephp
    networks:
      laravel_net:
        ipv4_address: 172.21.100.11
    environment:
      XDEBUG_CONFIG: remote_host=172.21.100.101 remote_port=9000 remote_enable=1
    expose:
      - "80"
    ports:
      - '80:80'
    volumes:
      - '/home/carlos/Escritorio/volumenes/web:/var/www/html'
    depends_on:
      - mysql
  node:
    container_name: node
    build:
      context: .
      dockerfile: ./Dockerfilenode
    restart: always
    networks:
      laravel_net:
        ipv4_address: 172.21.100.12
    expose:
      - "8000"
    ports:
      - '8000:8000'
    volumes:
      - '/home/carlos/Escritorio/volumenes/web/:/usr/src/app'
    depends_on:
      - mysql
volumes:
  mysql:
  web:
networks:
  laravel_net:
    driver: bridge
    ipam:
      driver: default
      config:
        - subnet: 172.21.100.0/24

**And those are the Dockerfiles:**
*(Dockerfilenode)*

FROM node:10-buster-slim
CMD npm run dev

(Dockerfilephp)

FROM 	php:7.4.16-apache-buster
RUN 	apt-get update && \
	docker-php-ext-install mysqli && \
	docker-php-ext-install pdo_mysql && \
	apt-get install -y curl && \
	apt-get install -y git && \
	apt-get install -y zip && \
	apt-get install -y unzip && \
	apt-get install -y nano && \
	curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer && \
	composer global require "laravel/installer" && \
	pecl install -f xdebug && \
	echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini && \
	echo "alias laravel='/root/.composer/vendor/bin/laravel'" > /root/.bashrc && \
	echo "\nxdebug.remote_connect_back=1\nxdebug.remote_enable=1 \nxdebug.remote_port=9000 \nxdebug.remote_handler=dbgp \nxdebug.remote_mode=req 	\nxdebug.profiler_enable=0\nxdebug.profiler_enable_trigger=1\	\nxdebug.remote_autostart=1 \	\nxdebug.idekey=PHPSTORM \	\nxdebug.remote_log='/tmp/xdebug.log' " >>  /usr/local/etc/php/conf.d/dockerphp-ext-xdebug.ini && \	
	rm -Rf /var/lib/apt/lists/*


Thanks a lot, i dont understand what is the problem with the node container.

Keep the following in mind when using restart policies:

A restart policy only takes effect after a container starts successfully. In this case, starting successfully means that the container is up for at least 10 seconds and Docker has started monitoring it. This prevents a container which does not start at all from going into a restart loop.

If you manually stop a container, its restart policy is ignored until the Docker daemon restarts or the container is manually restarted. This is another attempt to prevent a restart loop.

Restart policies only apply to containers. Restart policies for swarm services are configured differently. See the flags related to service restart.