skip to Main Content

It seems that when i run Docker compose up, docker is not reading from docker-compose.yml.
It seems like it is loading images from cache or i don’t think where is finding them.
Bellow is my docker-compose.yml

version: '3'

services:
  httpd:
    image: httpd:latest
    user: root
    ports:
        - "80:80"   # Default Apache port (Default on PHP 7.4)
        - "8073:8073" # PHP 7.3 Apache port
        - "8074:8074" # PHP 7.4 Apache port
        - "8081:8081" # PHP 8.1 Apache port
    volumes:
        - ./:/var/www/html/myApp/:rw
        - ./dev/Docker/httpd/httpd.conf:/usr/local/apache2/conf/httpd.conf
    restart: on-failure
    container_name: httpd
    networks:
      - mb-frontend

  php8.1-fpm:
    build: ./dev/Docker/php-fpm/8.1
    user: root
    environment:
      XDEBUG_ENABLED: 1
      XDEBUG_REMOTE_HOST: host.docker.internal
      PHP_IDE_CONFIG: serverName=localhost
    volumes:
      - ./:/var/www/html/myApp/:rw
    restart: on-failure
    container_name: php8.1-fpm
    networks:
      - mb-frontend
      - mb-backend

  php7.4-fpm:
    build: ./dev/Docker/php-fpm/7.4
    user: root
    environment:
      XDEBUG_ENABLED: 1
      XDEBUG_REMOTE_HOST: host.docker.internal
      PHP_IDE_CONFIG: serverName=localhost
    volumes:
      - ./:/var/www/html/myApp/:rw
    restart: on-failure
    container_name: php7.4-fpm
    networks:
      - mb-frontend
      - mb-backend

  php7.3-fpm:
    build: ./dev/Docker/php-fpm/7.3
    user: root
    environment:
      XDEBUG_ENABLED: 1
      XDEBUG_REMOTE_HOST: host.docker.internal
      PHP_IDE_CONFIG: serverName=localhost
    volumes:
        - ./:/var/www/html/myApp/:rw
    restart: on-failure
    container_name: php7.3-fpm
    networks:
      - mb-frontend
      - mb-backend

  db:
    image: mariadb:10.3.5
    environment:
      MYSQL_ROOT_PASSWORD: myPassword
      MYSQL_USER: dev
      MYSQL_PASSWORD: myPassword
    ports:
      - "3306:3306"
    volumes:
      - /root/Bureau/mysql:/var/lib/mysql/:rw
      - ./dev/Docker/mariadb/conf.d/:/etc/mysql/conf.d/:rw
      - ./dev/Docker/mariadb/config/init.sql:/docker-entrypoint-initdb.d/init.sql
    restart: on-failure
    container_name: db
    networks:
      - mb-backend

  phpmyadmin:
    image: phpmyadmin/phpmyadmin
    environment:
      PMA_HOST: db
    volumes:
      - /root/Bureau/phpmyadmin:/var/lib/mysql/
    networks:
      - mb-backend
    depends_on:
      - db

  redis:
    image: redis:6.2
    container_name: redis
    ports:
      - "6379:6379"
    networks:
      - mb-backend
networks:
  mb-frontend:
    driver: bridge
  mb-backend:
    driver: bridge

I commented some images on docker-compose.yml but when i tape the command Docker compose up on terminal, all images even commented images are Up.
Can anyone help me how i force docker to read images from the edited docker-compose.yml

2

Answers


  1. Good practice would be do use:

    docker compose down

    and then

    docker compose up

    UPDATE:

    Next I would suggest to clean up your containers:

    List all containers:

    docker ps -a

    Remove those you don’t want because they might still be in the system

    docker rm <CONTAINER ID/NAME>

    How to Stop & Remove a running container by ID or Name?

    Login or Signup to reply.
  2. The command is actually docker compose up.
    The command docker-compose has been deprecated as of latest version. We can now use docker compose without the hyphen(-).

    You can use docker-compose -f <path-to-compose-file> to pass in the compose file.

    Example:

    docker compose -f docker-compose.yml up
    

    Reference documentation: https://docs.docker.com/compose/reference/

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search