In order to give our non-root user access to the Docker management commands, we need to create a docker group (it may already be created for you), and then add your primary user to that group.
$ sudo groupadd docker
$ sudo usermod -aG docker $USER
By running this command, we ask Docker Compose to execute Bash on the PHP container:
docker-compose exec php bash