- 1 什么是Docker?
- 2 关于docker入门教程
- 3 准备
- 4 搜索可用docker镜像
- 5 下载容器镜像
- 6 在docker容器中运行hello world!
- 7 在容器中安装新的程序
- 8 保存对容器的修改
- 9 运行新的镜像
- 10 检查运行中的镜像
- 11 发布自己的镜像
在容器中安装新的程序
- 2014-01-15 20:18:56
- 王春生
- 595654
- 最后编辑:王春生 于 2014-02-15 09:31:52
在容器中安装新的程序
下一步我们要做的事情是在容器里面安装一个简单的程序(ping)。我们之前下载的tutorial镜像是基于ubuntu的,所以你可以使用ubuntu的apt-get命令来安装ping程序: apt-get install -y ping。
备注:apt-get 命令执行完毕之后,容器就会停止,但对容器的改动不会丢失。
目标:
在learn/tutorial镜像里面安装ping程序。
提示:
在执行apt-get 命令的时候,要带上-y参数。如果不指定-y参数的话,apt-get命令会进入交互模式,需要用户输入命令来进行确认,但在docker环境中是无法响应这种交互的。
正确的命令:
$docker run learn/tutorial apt-get install -y ping
评论列表
发表评论
docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.39/containers/create: dial unix /var/run/docker.sock: connect: permission denied.
See 'docker run --help'.
testadmin@test:~$ sudo docker run learn/tutorial apt-get install -y ping
Reading package lists...
Building dependency tree...
The following NEW packages will be installed:
iputils-ping
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 56.1 kB of archives.
After this operation, 143 kB of additional disk space will be used.
Err http://archive.ubuntu.com/ubuntu/ precise/main iputils-ping amd64 3:20101006-1ubuntu1
Temporary failure resolving 'archive.ubuntu.com'
Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/i/iputils/iputils-ping_20101006-1ubuntu1_amd64.deb Temporary failure resolving 'archive.ubuntu.com'
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
Reading package lists...
E: Unable to locate package ping
Building dependency tree...
Reading state information...
先进入容器 docker run -t -i ubuntu
apt-get update
apt-get upgrade
apt install iputils-ping # ping
container_linux.go:247:starting container process caused"exec::\"apt-get\":executable file not found in PATH$"
该怎么解决,是不提供下载了么?
Reading package lists...
E: Unable to locate package ping
Building dependency tree...
Reading state information...