Ask Your Question
2

What is the process of transforming `docker run -u user1:docker` into docker-compose?

asked 2023-04-29 05:57:31 +0000

nofretete gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2023-04-29 06:11:01 +0000

david gravatar image

To transform docker run -u user1:docker into docker-compose:

  1. Create a docker-compose.yml file in the root directory of your project.
  2. Add a version field at the beginning of the file, specifying the version of docker-compose you are using.
  3. Add a services field under which you will define the service you want to run.
  4. Under services, add a service name and define its image.
  5. Add a 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.

edit flag offensive delete link more

Your Answer

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

Add Answer


Question Tools

Stats

Asked: 2023-04-29 05:57:31 +0000

Seen: 15 times

Last updated: Apr 29 '23