将文件配置到码头运行 [英] Piping a file into docker run

查看:208
本文介绍了将文件配置到码头运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为运行命令的一部分,我需要将一个文件或一些数据导入(注入)一些数据,并将其作为启动的一部分写入容器内的一个文件。有最好的练习方法吗?



我已经尝试过了。

  cat data.txt | docker run -a stdin -a stdout -i -t ubuntu / bin / bash -c'cat> /data.txt'

但似乎无法让它工作。

解决方案

  cat setup.json |码头运行-i ubuntu / bin / bash -c'cat'

这对我有用。删除-t。不需要-a的。


I need to pipe (inject) a file or some data into docker as part of the run command and have it written to a file within the container as part of the startup. Is there best practise way to do this ?

I've tried this.

cat data.txt |  docker run -a stdin -a stdout -i -t ubuntu /bin/bash -c 'cat >/data.txt'

But can't seem to get it to work.

解决方案

cat setup.json |  docker run -i  ubuntu /bin/bash -c 'cat'

This worked for me. Remove the -t. Don't need the -a's either.

这篇关于将文件配置到码头运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆