Redirecting command output in docker

后端 未结 4 648
广开言路
广开言路 2020-12-01 04:26

I want to do some simple logging for my server which is a small Flask app running in a Docker container.

Here is the Dockerfile

# Dockerfile
FROM dre         


        
4条回答
  •  抹茶落季
    2020-12-01 04:50

    To use docker run in a shell pipeline or under shell redirection, making run accept stdin and output to stdout and stderr appropriately, use this incantation:

    docker run -i --log-driver=none -a stdin -a stdout -a stderr ...
    

    e.g. to run the alpine image and execute the UNIX command cat in the contained environment:

    echo "This was piped into docker" |
      docker run -i --log-driver=none -a stdin -a stdout -a stderr \
        alpine cat - |
      xargs echo This is coming out of docker: 
    

    emits:

    This is coming out of docker: This was piped into docker
    

提交回复
热议问题