Athena Wisdom
Athena Wisdom

Reputation: 6831

'docker-compose up' as a Different User Without Recreating Containers

A docker-compose.yml file was used to create a number of Docker containers by having user foo run docker-compose up -d. However, user foo is scheduled for deletion and we want a different user bar to be in charge to running these same containers. The docker-compose.yml file along with the mounted volumes must now be moved to a different location as well.

Is it possible now for user bar to take over control of the existing Docker containers, instead of having user foo perform docker-compose down and have user bar copy all the files to the new location, then run docker-compose up -d?

This way we will avoid having to redo setup steps in the newly created Docker containers created by user bar.

Upvotes: 1

Views: 1775

Answers (1)

David Maze
David Maze

Reputation: 158758

Docker doesn't have any concept of "user". Anyone who can reach the Docker daemon can perform any operation on any container.

In a Compose context, things are generally keyed off of a project name, which defaults to the name of the current directory. So if the project was previously in /home/foo/projects/thing, running docker-compose commands from /home/bar/projects/thing should find the same containers, volumes, and networks. (And if there are relative-path bind-mounts, it will want to move them to the new base directory.)

Upvotes: 2

Related Questions