在容器中安装新的程序

2014-01-15 20:18:56
王春生
672731
最后编辑:王春生 于 2014-02-15 09:31:52
简介:在docker容器中安装新的程序。

在容器中安装新的程序

下一步我们要做的事情是在容器里面安装一个简单的程序(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


评论列表
warsego 2022-08-04 10:11:49
ubuntu@VM-8-16-ubuntu:~$ sudo docker run learn/tutorial apt-get install -y ping
WARNING: The requested image's platform (unknown) does not match the detected host platform (linux/amd64) and no specific platform was requested
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
404 Not Found [IP: 185.125.190.39 80]
Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/i/iputils/iputils-ping_20101006-1ubuntu1_amd64.deb 404 Not Found [IP: 185.125.190.39 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
初学者 2019-03-11 22:55:28
testadmin@test:~$ 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?
vvtyzed.c 2019-03-04 09:30:26
说一下centos环境下安装工具啊,不能使用yum.
123 2019-04-23 13:39:46
https://www.runoob.com/docker/centos-docker-install.html
ferry 2017-08-09 18:08:24
像这样docker run learn/tutorial apt-get install -y ping ,只是安装一个工具到容器中,请问如果需要安装多个工具该如何操作呢
xietong 2017-07-28 20:22:38
出现
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
小白鼠 2017-06-26 14:00:43
docker run hello-world apt-get install -y ping 报错,信息如下:
container_linux.go:247:starting container process caused"exec::\"apt-get\":executable file not found in PATH$"
哈哈哈 2017-08-04 09:41:11
你这是在centos下运行的这个命令,不是ubunto
yandamin 2021-02-20 14:11:01
[root@iZl8b9ulg0x03pZ ~]# docker run learn/tutorial apt-get update
Ign http://archive.ubuntu.com precise InRelease
Hit http://archive.ubuntu.com precise Release.gpg
Hit http://archive.ubuntu.com precise Release
Hit http://archive.ubuntu.com precise/main amd64 Packages
Get:1 http://archive.ubuntu.com precise/main i386 Packages [1641 kB]
Get:2 http://archive.ubuntu.com precise/main TranslationIndex [3706 B]
Get:3 http://archive.ubuntu.com precise/main Translation-en [893 kB]
Fetched 2537 kB in 13s (187 kB/s)
Reading package lists...
[root@iZl8b9ulg0x03pZ ~]# docker run learn/tutorial apt-get install ping -y
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.
Get:1 http://archive.ubuntu.com/ubuntu/ precise/main iputils-ping amd64 3:20101006-1ubuntu1 [56.1 kB]
debconf: delaying package configuration, since apt-utils is not installed
Fetched 56.1 kB in 1s (29.0 kB/s)
Selecting previously unselected package iputils-ping.
(Reading database ... 7545 files and directories currently installed.)
Unpacking iputils-ping (from .../iputils-ping_3%3a20101006-1ubuntu1_amd64.deb) ...
Setting up iputils-ping (3:20101006-1ubuntu1) ...
这样就可以了
niunan 2017-06-24 20:56:56
fctf 运行成功。。。支持支持。
老爷 2017-04-21 11:52:29
请问我为什么commit之后怎么都启动不了呢?run不行,start也不行。。。。肿么办啊
wangsan 2017-03-02 16:42:11
Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
该怎么解决,是不提供下载了么?
benharden 2016-11-22 12:06:37
[root@localhost ~]# docker run ubuntu apt-get install -y ping
Reading package lists...
E: Unable to locate package ping
Building dependency tree...
Reading state information...
icegxt 2017-02-06 23:06:06
请问你的这个问题解决了吗?
1/2
发表评论
捌 乘 零 =
评论通过审核后显示。