Nginx Docker container always restarting

My current docker-compose.yml looks like this:

version: '3'

services:

    testsite-nginx:
        image: nginx:alpine
        container_name: test_site_nginx
        restart: unless-stopped
        tty: true
        volumes:
            - ./nginx.conf:/etc/nginx/nginx.conf
            - ./example.co.uk:/var/www
        ports:
            # I do want to map it to port 8080 on my local machine, not 80
            - 8080:80
        networks:
            - app-network

    testsite-mysql:
        image: mysql:5.7.22
        container_name: test_site_mysql
        restart: unless-stopped
        tty: true
        ports:
            # I do want to map it to port 3309 on my local machine, not 3306
            - 3309:3306
        environment:
            MYSQL_DATABASE: laravel
            MYSQL_ROOT_PASSWORD: somethingreallysecure
            SERVICE_TAGS: dev
            SERVICE_NAME: mysql
        volumes:
            - dbdata:/var/lib/mysql/
            - ./example.co.uk/mysql/my.cnf:/etc/mysql/my.cnf
        networks:
            - app-network

    testsite-app:
        build:
            context: .
        image: example.co.uk/app
        container_name: test_site_app
        restart: unless-stopped
        tty: true
        environment:
            SERVICE_NAME: app
            SERVICE_TAGS: dev
        working_dir: /var/www
        volumes:
            - ./php/local.ini:/usr/local/etc/php/conf.d/local.ini
            - ./example.co.uk:/var/www
        depends_on:
            - testsite-nginx
            - testsite-mysql
        networks:
            - app-network

networks:
    app-network:
        driver: bridge

volumes:
    dbdata:
        driver: local

However, when I run a docker-compose up --build -d and then run docker-compose ps I can see that my nginx container is always restarting:

$ docker-compose ps
     Name                    Command                 State              Ports
--------------------------------------------------------------------------------------
test_site_app     docker-php-entrypoint php-fpm    Up           9000/tcp
test_site_mysql   docker-entrypoint.sh mysqld      Up           0.0.0.0:3309->3306/tcp
test_site_nginx   /docker-entrypoint.sh ngin ...   Restarting

I have tried using the tty: true as stated on previous ServerFault questions but this has not fixed the issue as seen above. Any solutions to this?


Upon executing docker compose logs test_site_nginx, thanks to a user on Redit, I saw this error:

2021/01/20 12:37:18 [emerg] 1#1: invalid number of arguments in "user" directive in /etc/nginx/nginx.conf:2
nginx: [emerg] invalid number of arguments in "user" directive in /etc/nginx/nginx.conf:2

Turns out I was missing a semi-colon ending a configuration line when declaring

user www-data; # <-- I did not have the ;

After a restart, the service booted as expected and my logs where running fine.