Answer the question
In order to leave comments, you need to log in
How to set up .bash_history in a container if the container user is not root?
Background:
In order not to suffer with changing the rights to files that are created from the php container, I made the transfer of users from the host machine inside the container in the docker-compose.yml file.
Current problem:
I wanted to add command history saving inside php container, found similar examples that show that you need to map .bash_history file to host machine with /root/.bash_history file inside container.
Only the root user has access to the /root folder, so launching the container from under the host user loses its usefulness.
How to configure history storage correctly?
Docker-compose.yaml snippet:
php-fpm:
user: ${HOST_USER} #проброс пользователя
working_dir: /app
build:
context: ./docker/php-fpm
dockerfile: Dockerfile
volumes:
- .:/app
- ./docker/php-fpm/log/:/var/log/
- ./docker/php-fpm/bash/.bash_history:/root/.bash_history #проброс истории команд
- /etc/group:/etc/group:ro #проброс пользователя
- /etc/passwd:/etc/passwd:ro #проброс пользователя
ports:
- '9000:9000'
networks:
- internal
Answer the question
In order to leave comments, you need to log in
I wanted to add saving the command history inside the php container, I found examples of the same type that show that you need to map the .bash_history file to the host machine with the /root/.bash_history file inside the container.If you need the history not of the root, but of another user, then you need to map
/home/%username%/.bash_history
.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question