I have following docker command to run container
docker run -d --name test -v /etc/hadoop/conf:/etc/hadoop/conf -v /usr/lib/python2.7/dist-packages/hdinsight_common:/usr/lib/python2.7/dist-packages/hdinsight_common -v /etc/hive/conf/:/etc/hive/conf/ -v /etc/tez/conf/:/etc/tez/conf/ -v /usr/hdp/2.4.2.0-258/sqoop/lib/:/usr/hdp/2.4.2.0-258/sqoop/lib/ -i -t hdinsight /bin/bash
This was to complicated so I was trying to create docker-compose file like this
version: '2' services: hdinsight: image: hdinsight container_name: ABC volumes: - /etc/hadoop/conf:/etc/hadoop/conf - /usr/lib/python2.7/dist-packages/hdinsight_common:/usr/lib/python2.7/dist-packages/hdinsight_common - /etc/hive/conf/:/etc/hive/conf/ - /etc/tez/conf/:/etc/tez/conf/ - /usr/hdp/2.4.2.0-258/sqoop/lib/:/usr/hdp/2.4.2.0-258/sqoop/lib/ entrypoint: - bash labels: - "HDInsight client VM"
But I am not sure where to pass -d
, -i
& -t
flages from my original docker run command
I was running docker-compose like this
docker-compose -f docker-compose.yml run hdinsight
can anyone point me to right direction here ?
UPDATE after first answer
I tried to run docker-compose up -d
root@abc-docker:~/ubuntu# docker-compose up -d Creating ABC root@sbd-docker:~/ubuntu# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES ffa4c359abf7 hdinsight "/bin/bash" 5 seconds ago Exited (0) 5 seconds ago ABC root@sbd-docker:~/ubuntu#
Dont know why its in Exited
status
Any idea ?
Thanks
to stop a docker process and release the ports, first use ctrl - c to leave the exit the container then use docker ps to find the list of running containers. Then you can use the docker container stop to stop that process and release its ports.
Detached (-d) mode in Docker – Explained We use Docker detached mode (-d) when we want to connect to the container in an interactive mode or we can say when we just want application to be running inside the container. This means, we can start up the container and could use the console after startup for other commands.
The docker-compose up command aggregates the output of each container (essentially running docker-compose logs -f ). When the command exits, all containers are stopped. Running docker-compose up -d starts the containers in the background and leaves them running.
A Dockerfile is a simple text file that contains the commands a user could call to assemble an image whereas Docker Compose is a tool for defining and running multi-container Docker applications. Docker Compose define the services that make up your app in docker-compose.
You should scour the Compose file docs.
Most docker run commands have a compose equivalent, and they should all be listed there.
The background flag -d goes after run or up.
The tty flag -t and interactive flag -i are not required as docker-compose run does this by default. You can add tty to individual containers in the compose file with -t, but you cannot use interactive mode since you may start multiple containers at once and you can't interact with them all.
In regard to your situation the command you're using should be working. If you add -d after the run command it will run in the background. But I recommend using up instead of run, as it will simply start all containers in the file rather than you having to specify hdinsight.
As said by Anand Suthar, you have to use tty: true
and stdin_open: true
. Here is a minimal example:
version: "3" services: alpine1: image: alpine tty: true stdin_open: true
Start with:
docker-compose up -d
Attach to a container with:
docker attach 268bcfb650fb
and detach with ^P^Q
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With