How to docker-composer up as non-root user

I installed docker with sudo apt install docker.io.
grep /etc/group -e "sudo" gives admin and grep /etc/group -e "docker" gives www-data,admin. I want to docker-compose up as www-data. How to do it. I am new to docker.

You can use the sudo usermod -aG docker www-data command to add the www-data user to the docker group. This will allow the www-data user to run docker commands without using sudo .

Next, you need to log out and log back in for this change to take effect.

Once that is done, you can use the docker-compose up command as the www-data user to start your application.