Docker sees the old configuration file

Hello,
The Dockerfile is as follows:

FROM nginx:latest

WORKDIR /usr/share/nginx/html

RUN mkdir -p /var/www/empty-webroot/

COPY ./nginx.conf /etc/nginx/nginx.conf

The nginx.conf file is as follows:

worker_processes 1;

events { worker_connections 10000; }

http {

  sendfile on;

  gzip              on;
  gzip_http_version 1.0;
  gzip_proxied      any;
  gzip_min_length   999;
  gzip_disable      "MSIE [1-6]\.";
  gzip_types        text/plain text/xml text/css
                    text/comma-separated-values
                    text/javascript
                    application/x-javascript;

  upstream M1-Micro {

  server M1:3000;

  }

  upstream M2-Micro {

  server M2:3001;

  }

  upstream M3-Micro {

  server M3:3002;

  }

    server {

    listen 80;
    server_name default_server;
    error_log  /var/log/nginx/error.system-default.log;
    access_log /var/log/nginx/access.system-default.log;
    charset utf-8;

    location /M1 {

    proxy_pass         http://M1-Micro;
    proxy_redirect     off;
    proxy_set_header   Host $host;
    proxy_set_header   X-Real-IP $remote_addr;
    proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header   X-Forwarded-Host $server_name;

    }
  
    location /M2 {

    proxy_pass         http://M2-Micro;
    proxy_redirect     off;
    proxy_set_header   Host $host;
    proxy_set_header   X-Real-IP $remote_addr;
    proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header   X-Forwarded-Host $server_name;

    }

    location /M3 {

    proxy_pass         http://M3-Micro;
    proxy_redirect     off;
    proxy_set_header   Host $host;
    proxy_set_header   X-Real-IP $remote_addr;
    proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header   X-Forwarded-Host $server_name;

    }
  }
}

I run the container and get the following error message:

$ docker compose up nginx
[+] Running 1/1
 ✔ Container Nginx       Created                                                                                                                    0.1s 
Attaching to Nginx
Nginx  | /docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
Nginx  | /docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
Nginx  | /docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
Nginx  | 10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf
Nginx  | 10-listen-on-ipv6-by-default.sh: info: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf
Nginx  | /docker-entrypoint.sh: Sourcing /docker-entrypoint.d/15-local-resolvers.envsh
Nginx  | /docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
Nginx  | /docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
Nginx  | /docker-entrypoint.sh: Configuration complete; ready for start up
Nginx  | 2024/05/06 12:06:33 [emerg] 1#1: host not found in upstream "yaml-contractor:3001" in /etc/nginx/nginx.conf:27
Nginx  | nginx: [emerg] host not found in upstream "yaml-contractor:3001" in /etc/nginx/nginx.conf:27
Nginx exited with code 1

The yaml-contractor:3001 does not exist on line 27.
I ran the following commands but it didn’t work:

$ docker ps -a
$ docker rm Container_Name
$ docker compose down -v Service_Name

But these did not solve the problem.

Thank you.

Images will not be rebuilt unless you use the --build flag after “up”.

docker compose up --build nginx