# ansible docker\_service - how to specify user to run container

**URL:** <https://forum.ansible.com/t/ansible-docker-service-how-to-specify-user-to-run-container/24774>\
**Category:** Ansible Project\
**Tags:** rhel\
**Created:** [June 20, 2017, 6:00pm UTC](https://forum.ansible.com/t/ansible-docker-service-how-to-specify-user-to-run-container/24774 "2017-06-20T18:00:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mark\_Chassy](https://avatars.discourse-cdn.com/v4/letter/m/7c8e57/32.png) [@Mark\_Chassy](https://forum.ansible.com/u/Mark_Chassy)\
**Post date:** [June 20, 2017, 6:00pm UTC](https://forum.ansible.com/t/ansible-docker-service-how-to-specify-user-to-run-container/24774/1 "2017-06-20T18:00:36Z")

</div>

setup  
client  
installed with

> ansible 2.3.1.0  
> python version = 2.7.12 (v2.7.12:d33e0cf91556, Jun 26 2016, 12:10:39) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]

host: RHEL 7  
installed with

> docker version 17.05.0-ce, build 89658be
> 
> docker-compose version 1.13.0, build 1719ceb

> base image: ansible/centos7-ansible

Basic setup  
A first ansible script

- sets up the host server with docker, docker-compose, etc …

- syncs the files necessary to create 2 containers: Apache tomEE and Mongo

- Dockerfile, playbook.yml, vars.yml + any additional artefacts needed  
The base container is ansible/centos7-ansible and NOT mongo or tomee because I want to set up specific installs.  
Each images gets a specific playbook which is run during the build process  
The last section of the master ansible script is this

`

- name: build and start both containers in compose style  
docker\_service:  
state: “present”  
project\_src: “{{ host\_home }}”  
project\_name: “orson”  
restarted: “yes”  
`

This section effectively builds the images and set them running on the same virtual network. And all of this works.  
I just need to do one last thing. Part of the specific install is to create an application user and have all processes run under that user.  
In native docker I can run

`  
docker run -u username --name container\_name -d image\_name

`

But I don’t see any equivalent of the -u option in the docker\_service module.  
Did I miss it? Or is there a way to pass it through another way.

Thanks for any help
