Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable output on one of containers?

I am using Codeship CI for my project. I have selenium tests and I am using remote browser from selenium/standalone-firefox but it's producing tons of logs, so I want to disable stdout for selenium/standalone-firefox container.

Any ideas how I can do this?

like image 960
Blejwi Avatar asked Oct 12 '16 10:10

Blejwi


People also ask

What is detached mode in container?

Detached mode, shown by the option --detach or -d , means that a Docker container runs in the background of your terminal. It does not receive input or display output.

How do I stop a container from command line?

To stop a container you use the docker stop command and pass the name of the container and the number of seconds before a container is killed. The default number of seconds the command will wait before the killing is 10 seconds.

How do I stop a container from running as root?

The best way to prevent privilege-escalation attacks from within a container is to configure your container's applications to run as unprivileged users. For containers whose processes must run as the root user within the container, you can re-map this user to a less-privileged user on the Docker host.


1 Answers

Use --log-driver=none in docker run:

docker run -d --log-driver=none selenium/standalone-firefox 

Or docker-compose.yml

version: '2' services:   selenium:     ports:       - "4444:4444"     logging:       driver: "none"      image:       selenium/standalone-firefox 

You can also send the log to a file using:

docker run -d --log-driver=none -e SE_OPTS="log log.txt" selenium/standalone-firefox 

Or docker-compose.yml

version: '2' services:   selenium:     ports:       - "4444:4444"     logging:       driver: "none"     environment:       - SE_OPTS="log log.txt"      image:       selenium/standalone-firefox 

For docker-compose file version 1 there is no other way than modifying the entry_point.sh

put this file next your docker-compose.yml entry_point.sh

#!/bin/bash  source /opt/bin/functions.sh  export GEOMETRY="$SCREEN_WIDTH""x""$SCREEN_HEIGHT""x""$SCREEN_DEPTH"  function shutdown {   kill -s SIGTERM $NODE_PID   wait $NODE_PID }  if [ ! -z "$SE_OPTS" ]; then   echo "appending selenium options: ${SE_OPTS}" fi  SERVERNUM=$(get_server_num) xvfb-run -n $SERVERNUM --server-args="-screen 0 $GEOMETRY -ac +extension RANDR" \   java ${JAVA_OPTS} -jar /opt/selenium/selenium-server-standalone.jar \   ${SE_OPTS} >/dev/null & NODE_PID=$!  trap shutdown SIGTERM SIGINT wait $NODE_PID 

The use this docker-compose.yml:

selenium:   ports:     - "4444:4444"    volumes:     - .:/mnt   image:     selenium/standalone-firefox   command: bash /mnt/entry_point.sh >/dev/null 

Regards

like image 186
Carlos Rafael Ramirez Avatar answered Sep 17 '22 05:09

Carlos Rafael Ramirez