To transform docker run -u user1:docker
into docker-compose:
docker-compose.yml
file in the root directory of your project.version
field at the beginning of the file, specifying the version of docker-compose you are using.services
field under which you will define the service you want to run.services
, add a service name and define its image
.user
field under the service definition and specify the user and group you want to run the container as.The final docker-compose file would look something like this:
version: "3"
services:
my_service:
image: "my_image"
user: "user1:docker"
This docker-compose.yml
file will create a service named my_service
and run it with the user1
user and docker
group.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2023-04-29 05:57:31 +0000
Seen: 15 times
Last updated: Apr 29 '23
How can I speed up Docker operations on WSL2?
How can a connection be established on a local network through Docker and Bridge?
What is the process for preserving all Docker images and transferring them to a different device?
How can GPU memory be shared among various Docker containers?
How can I eliminate a network that has been deleted from a Docker container?
What is the cause of port conflict when scaling docker compose services?
Is it not possible to use composer with Docker container when using Laravel Sail?