2014-12-03 34 views
1

有没有一种方法可以在发出docker run命令的终端中显示回显。如果没有使用-d选项,这里只显示echo。我可以做码头日志来查看这些回声,但我想知道是否有方法让他们直接在终端发出运行命令?Docker:用于运行Docker的终端的回显图像

Dockerfile:

# Generic Docker Image for Running Node app from Git Repository 
FROM node:0.10.33-slim 
ENV NODE_ENV production 

# Add script to pull Node app from Git and run the app 
COPY docker-node-entrypoint.sh /entrypoint.sh 
RUN chmod +x /entrypoint.sh 
ENTRYPOINT ["/entrypoint.sh"] 

EXPOSE 8080 
CMD ["--help"] 

入口点脚本:

#!/bin/bash 
set -e 
# Run the command passed in if it isn't to start a node app 
if [ "$1" != 'node-server' ]; then 
    exec "[email protected]" 
fi 
# Logic for pulling the node app and starting it 
cd /usr/src 
# try to remove the repo if it already exists 
rm -rf node-app; true 
echo "Pulling Node app's source from $2" 
git clone $2 node-app 
cd node-app 
# Check if we should be running a specific commit from the git repo 
if [ ! -z "$3" ]; then 
    echo "Changing to commit $3" 
    git checkout $3 
fi 
npm install 
echo "Starting the app" 
exec node . 

回答

1

你可以有两种-d或标准输出,但不能同时使用。如果你想在后台运行与标准输出的容器,你可以使用&

$ docker run ubuntu echo "Stdout from container" & 
[1] 2751 
$ Stdout from container 

或者你可以使用-d和搬运工日志-f