Docker-compose: build image but uses another one

I’m trying to set up WordPress using docker-compose but WordPress has to work in a separated container with php_fpm, a container for mondodb, and an Nginx in port 443 redirecting to WordPress if the link was HTTPS://localhost/wordpress but if the link was HTTPS://localhost/ it has to send the request to index.html page on the same container.

Docker-compose builds my custom Nginx image, but in the cluster, it runs a default Nginx container. And I don’t know where it’s coming from.

docker-compose.yml:

version: '3'
services:
  mysql:
    image: mariadb:latest
    container_name: mariadb
    volumes:
      - /data/mysql:/var/lib/mysql
    environment:
      MYSQL_ROOT_PASSWORD: mysql_root_pass
      MYSQL_DATABASE: db_name
      MYSQL_USER: user_name
      MYSQL_PASSWORD: user_pass
    restart: always
  wordpress:
    image: wordpress:php7.3-fpm-alpine
    volumes:
      - /data/html:/var/www/html
    container_name: wordress
    depends_on:
      - mysql
    ports: ['9000:9000']
    environment:
      WORDPRESS_DB_HOST: mysql
      MYSQL_ROOT_PASSWORD: mysql_root_pass
      WORDPRESS_DB_NAME: db_name
      WORDPRESS_DB_USER: user_name
      WORDPRESS_DB_PASSWORD: user_pass
      WORDPRESS_TABLE_PREFIX: wp_
    links:
      - mysql
    restart: always
  nginx:
    build: nginx
    image: nginx/test
    container_name: nginx
    volumes:
      - /data/html:/var/www/html
    ports:
      - 443:443
    links:
      - wordpress

nginx dockerfile:

FROM  alpine:3.12.0

RUN apk update
RUN apk add nginx openrc vim
RUN apk add php7-common php7-iconv php7-json php7-gd php7-curl php7-xml \
	php7-mysqli php7-imap php7-cgi fcgi php7-pdo php7-pdo_mysql php7-soap php7-xmlrpc \
	php7-posix php7-mcrypt php7-gettext php7-ldap php7-ctype php7-dom php7 php7-fpm php7-opcache openssl

COPY src ./tmp/
RUN mkdir -p /var/www/html/test

RUN cp /tmp/index.html /var/www/html/test/

RUN openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/nginx-selfsigned.key -out /etc/ssl/certs/nginx-selfsigned.crt -subj "/C=MA/ST=Khouribga/L=Khouribga/O=1337/CN=ft_services"

RUN mv /tmp/default.conf /etc/nginx/conf.d/
RUN openrc
RUN touch /run/openrc/softlevel

ADD src/run.sh .
RUN chmod +x /run.sh


ENTRYPOINT [ "/run.sh" ]

I’d say that despite the build part, at run time this will use an image named test from https://hub.docker.com/r/nginx, though I don’t see a public test image there.

(Next time, if you must really post in multiple locations, then please let people know about that. And keep all places in sync please.)