Tag: bash

Shell脚本使用grep清理指定的docker容器

我想编写一个脚本,由我的开发构build服务器执行,在构build和运行新容器之前将删除所有“类似”泊坞窗容器。 下面是我需要的bash脚本的伪代码 var name = $1 var number_of_results = # of containers returned from $(docker ps -a | grep "$name") if(number_of_result > 0) docker rm -f $(docker ps -a | grep "$name")

如何为Docker命令写入参数化的Bash别名

我目前正面临一个问题。 我只是拉了一个Vim容器在CoreOs系统上使用它。 我尝试创build一个别名来启动Vim容器,而不是已经存在的容器(主要是因为在这个容器上我可以安装不同的插件) 但目前它不起作用,我不知道为什么。 该容器在/home/dev上具有卷挂接 我的别名: alias dockervim="docker run -ti –rm -v \"\$(pwd)\":/home/dev vimpadawan bash -c "vim \"\$1\""" 但是,当我写dockervim file_name它启动Vim,但不是与文件。 有人有什么想法? docker版本 Client version: 1.6.2 Client API version: 1.18 Go version (client): go1.4.2 Git commit (client): 7c8fca2-dirty OS/Arch (client): linux/amd64 Server version: 1.6.2 Server API version: 1.18 Go version (server): go1.4.2 Git commit (server): 7c8fca2-dirty […]

如何在Dockerfile中设置.bash_profile环境variables?

我想在Dockerfile中设置bash环境variables。 我怎么能做到这一点? 主机:OS X 10.11.4 客户:Ubuntu的:最新 Dockerfile: RUN mkdir ~/gopath_dir RUN apt-get install ubuntu-make RUN umake go # I want to set $GOPATH to ~/gopath_dir

我如何设置$ Dockerfile $ PS1?

如何在Dockerfile中设置PS1环境variables(bash提示符)? 我尝试过ENV PS1 "\h:\W \u$ " 但是这个命令不会改变提示。 我不知道为什么上面的ENV没有设置PS1提示。 我该怎么做?

在容器中设置ENVvariables不工作,是否在容器运行时执行“/ usr / local / bin”下的每一个?

我在Dockerfile有以下的定义: # This aims to be the default value if -e is not present on the run command ENV HOST_IP=127.0.0.1 … COPY /container-files/etc/php.d/zz-php.ini /etc/php5/mods-available/zz-php.ini RUN ln -s /etc/php5/mods-available/zz-php.ini /etc/php5/apache2/conf.d/zz-php.ini COPY /container-files/init-scripts/setup_xdebug_ip.sh /usr/local/bin/setup_xdebug_ip.sh RUN chmod +x /usr/local/bin/setup_xdebug_ip.sh CMD ["/usr/local/bin/setup_xdebug_ip.sh", "/usr/local/bin/setup_php_settings.sh"] 这是zz-php.ini的相关定义: ; Xdebug [Xdebug] xdebug.remote_enable=true xdebug.remote_host="192.168.3.1" => this should be overwrited by HOST_IP xdebug.remote_port="9001" xdebug.idekey="XDEBUG_PHPSTORM" 这是脚本setup_xdebug_ip.sh的内容: […]

Android / busybox / termuxtestingenvionment

我正在开发一些在Linux / BSD / Mac / Windows上运行的bash脚本。 我想将它们移植到busybox环境中,让它们在androidterminal模拟器(如termux)中运行。 获取busybox / androidtesting环境的最佳方法是什么? 我试图去与docker的busybox图像。 我还需要能够添加工具,如ssh客户端或rsync,它通过apt install rsync工作在android termux中,但不会在docker镜像中工作,原因很明显。 有任何想法吗 ? 谢谢。

Dockerfile – 如何将答案传递给提交后apt-get安装?

在我的Dockerfile中,我试图安装jackd2软件包: RUN apt-get install -y jackd2 它安装正确,但安装后,我可以看到以下提示: If you want to run jackd with realtime priorities, the user starting jackd needs realtime permissions. Accept this option to create the file /etc/security/limits.d/audio.conf, granting realtime priority and memlock privileges to the audio group. Running jackd with realtime priority minimizes latency, but may lead to complete system lock-ups […]

在Docker容器启动时启动bash脚本不起作用

在过去的几个小时里,我一直试图在Docker容器启动时启动我的startup.sh脚本,但由于某种原因,它不起作用。 我的Dockerfile来创build图像: FROM armv7/armhf-ubuntu:latest MAINTAINER Mohammed Noureldin <mne@hotmail.com> RUN apt update && apt upgrade -y && apt install -y mumble-server ADD scripts/startup.sh /startup.sh 我的启动脚本: #!/bin/bash /etc/init.d/mumble-server start 这里没有任何反应,虽然我试图在脚本内创build一个文件,但也没有发生任何事情! 我试图直接从命令行执行脚本,但它不工作我不知道为什么: docker运行命令: docker run –name murmur -itd –restart always –network bridge -p 64738:64738 -v /var/lib/mumble-server/ -v /etc/ mnoureldin/murmur:latest /bin/bash -c "bash /startup.sh;/bin/bash" 在这里,我试图手动执行脚本时得到的是: 43b9d8dd4116bc605537c7af35ab186ca165ea6e957fab5908d39b2f085edf41 mohammed@server01:~/Dockerfiles/Mumble $ docker […]

将parameter passing给另一个进程,因为它们是通过bash脚本在命令行中input的

不知道我把这个称为好,因为我无法find答案,我很高兴使用类似的术语,但在这里。 这就是情况,我们在Docker容器中运行一些服务,它们都在各自的VLAN中。 Docker方便地为各个容器添加条目,以便应用程序可以从其容器名称中parsing其他地址。 例如我有一个名为应用程序的容器和一个名为devsql的容器,运行一个mysql服务器。 如果我使用exec从应用程序容器中运行ping devsql ,则会解决问题并对其进行处理。 但是,如果我从主机运行ping devsql ,它不知道是什么。 我们的应用程序是一个laravel应用程序,我们编写迁移,然后我们使用“工匠”脚本来执行。 通常,这看起来像php artisan migrate 。 但是,configuration使用devsql作为mysql服务器的地址,这对容器来说很好,但是主机无法解决这个问题,所以迁移会抛出一个错误。 我们的解决scheme是从vlan上的一个实用程序容器中运行它,所以相应的命令是docker run -it –rm –network=environment_network -v /var/www/html/whatever:/whatever util -c "cd /whatever && php artisan migrate"显然,这是最好的麻烦,最坏的情况是混淆新员工的一件事。 所以我想把它包装在一个脚本中。 我希望脚本能像正在运行常规php一样工作。 对于上面的例子,这很容易,但我想它来处理例如php -r "echo 'lol'"; 。 我不希望用户必须知道他们需要考虑多次扩展。 我有一个脚本,但我不知道它是多么脆弱,我想知道是否有更好的方法来实现这一点: #!/bin/bash # echo "cd /pwd && php $@" # Assume that any argument with spaces […]

如何运行docker容器,而无需进入容器

我有Dockefile FROM centos:7 所以我没有在dockerfile中的入口点。 然后我build立它的形象 sudo docker build -t my_container . 然后我开始。 sudo docker run -t my_container 我打开容器的tty root@my_container_id/ 如果我没有开始,就马上停止。 如何运行docker容器没有启动tty和没有入口点?