签到成功

知道了

CNDBA社区CNDBA社区

Docker 更改debian 源 并安装 vim 工具

2020-03-29 13:28 3510 0 原创 Docker
作者: dave

在之前的博客我们搭建了基本得Docker 环境。 如下:

http://www.cndba.cn/cndba/dave/article/4105

Linux 7.7 安装 Docker
https://www.cndba.cn/dave/article/4100

但是使用vim更改docker 中的文件时,提示没有vim 命令。http://www.cndba.cn/cndba/dave/article/4105http://www.cndba.cn/cndba/dave/article/4105http://www.cndba.cn/cndba/dave/article/4105http://www.cndba.cn/cndba/dave/article/4105

[root@www.cndba.cn ~]# docker exec -it mysqlserver bash
root@34ad82852c64:/# vi /etc/mysql/my.cnf
bash: vi: command not found

此时需要安装vim 命令,但通过debian 官方的源,更新太慢:http://www.cndba.cn/cndba/dave/article/4105

root@34ad82852c64:/# apt-get update
Get:1 http://security.debian.org/debian-security buster/updates InRelease [65.4 kB]
Get:2 http://repo.mysql.com/apt/debian buster InRelease [21.5 kB]
Get:3 http://repo.mysql.com/apt/debian buster/mysql-8.0 amd64 Packages [7139 B]
Get:4 http://security.debian.org/debian-security buster/updates/main amd64 Packages [185 kB]
Get:5 http://deb.debian.org/debian buster InRelease [122 kB]
Get:6 http://deb.debian.org/debian buster-updates InRelease [49.3 kB]
Get:7 http://deb.debian.org/debian buster/main amd64 Packages [7907 kB]
Get:8 http://deb.debian.org/debian buster-updates/main amd64 Packages [7380 B]
Fetched 8364 kB in 6min 17s (22.2 kB/s)
Reading package lists... Done
root@34ad82852c64:/# apt-get install viim
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package viim
root@34ad82852c64:/# apt-get install vim
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  vim-common vim-runtime xxd
Suggested packages:
  ctags vim-doc vim-scripts
The following NEW packages will be installed:
  vim vim-common vim-runtime xxd
0 upgraded, 4 newly installed, 0 to remove and 0 not upgraded.
Need to get 7390 kB of archives.
After this operation, 33.7 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://deb.debian.org/debian buster/main amd64 xxd amd64 2:8.1.0875-5 [140 kB]
Get:2 http://deb.debian.org/debian buster/main amd64 vim-common all 2:8.1.0875-5 [195 kB]
Get:3 http://deb.debian.org/debian buster/main amd64 vim-runtime all 2:8.1.0875-5 [5775 kB]
Get:4 http://deb.debian.org/debian buster/main amd64 vim amd64 2:8.1.0875-5 [1280 kB]
84% [4 vim 226 kB/1280 kB 18%]

所以需要更改apt-get的源,但docker中现在还没有vim命令,所以无法直接修改。这里使用cp命令,曲线救国一下,先将源文件cp到物理主机,修改之后,在cp回去。http://www.cndba.cn/cndba/dave/article/4105

http://www.cndba.cn/cndba/dave/article/4105
http://www.cndba.cn/cndba/dave/article/4105

Docker 命令大全
https://www.cndba.cn/dave/article/4104

[root@www.cndba.cn conf]# docker cp 4e327b82cd18:/etc/apt/sources.list /tmp
[root@www.cndba.cn ~]# docker cp /tmp/sources.list mysqlserver:/etc/apt/

root@34ad82852c64:/etc/apt# pwd
/etc/apt
root@34ad82852c64:/etc/apt# cat sources.list
deb http://mirrors.163.com/debian/ buster main
deb-src http://mirrors.163.com/debian/ buster main
root@34ad82852c64:/etc/apt#


root@34ad82852c64:/# apt-get update
Get:1 http://mirrors.163.com/debian buster InRelease [122 kB]
Get:2 http://mirrors.163.com/debian buster/main Sources [7832 kB]
Hit:3 http://repo.mysql.com/apt/debian buster InRelease
Get:4 http://mirrors.163.com/debian buster/main amd64 Packages [7907 kB]
Fetched 15.9 MB in 3s (5676 kB/s)
Reading package lists... Done
root@34ad82852c64:/# apt-get install vim
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  vim-common vim-runtime xxd
Suggested packages:
  ctags vim-doc vim-scripts
The following NEW packages will be installed:
  vim vim-common vim-runtime xxd
0 upgraded, 4 newly installed, 0 to remove and 0 not upgraded.
Need to get 7390 kB of archives.
After this operation, 33.7 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://mirrors.163.com/debian buster/main amd64 xxd amd64 2:8.1.0875-5 [140 kB]
Get:2 http://mirrors.163.com/debian buster/main amd64 vim-common all 2:8.1.0875-5 [195 kB]
Get:3 http://mirrors.163.com/debian buster/main amd64 vim-runtime all 2:8.1.0875-5 [5775 kB]
Get:4 http://mirrors.163.com/debian buster/main amd64 vim amd64 2:8.1.0875-5 [1280 kB]
Fetched 7390 kB in 1s (4941 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package xxd.
(Reading database ... 9223 files and directories currently installed.)
Preparing to unpack .../xxd_2%3a8.1.0875-5_amd64.deb ...
Unpacking xxd (2:8.1.0875-5) ...
Selecting previously unselected package vim-common.
Preparing to unpack .../vim-common_2%3a8.1.0875-5_all.deb ...
Unpacking vim-common (2:8.1.0875-5) ...
Selecting previously unselected package vim-runtime.
Preparing to unpack .../vim-runtime_2%3a8.1.0875-5_all.deb ...
Adding 'diversion of /usr/share/vim/vim81/doc/help.txt to /usr/share/vim/vim81/doc/help.txt.vim-tiny by vim-runtime'
Adding 'diversion of /usr/share/vim/vim81/doc/tags to /usr/share/vim/vim81/doc/tags.vim-tiny by vim-runtime'
Unpacking vim-runtime (2:8.1.0875-5) ...
Selecting previously unselected package vim.
Preparing to unpack .../vim_2%3a8.1.0875-5_amd64.deb ...
Unpacking vim (2:8.1.0875-5) ...
Setting up xxd (2:8.1.0875-5) ...
Setting up vim-common (2:8.1.0875-5) ...
Setting up vim-runtime (2:8.1.0875-5) ...
Setting up vim (2:8.1.0875-5) ...
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vim (vim) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vimdiff (vimdiff) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/rvim (rvim) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/rview (rview) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vi (vi) in auto mode

root@34ad82852c64:/# which vim
/usr/bin/vim

在更新就搜一下结束了,不用等待漫长的几十分钟了。

http://www.cndba.cn/cndba/dave/article/4105

版权声明:本文为博主原创文章,未经博主允许不得转载。

用户评论
* 以下用户言论只代表其个人观点,不代表CNDBA社区的观点或立场
dave

dave

关注

人的一生应该是这样度过的:当他回首往事的时候,他不会因为虚度年华而悔恨,也不会因为碌碌无为而羞耻;这样,在临死的时候,他就能够说:“我的整个生命和全部精力,都已经献给世界上最壮丽的事业....."

  • 2296
    原创
  • 3
    翻译
  • 582
    转载
  • 198
    评论
  • 访问:8508427次
  • 积分:4477
  • 等级:核心会员
  • 排名:第1名
精华文章
    最新问题
    查看更多+
    热门文章
      热门用户
      推荐用户
        Copyright © 2016 All Rights Reserved. Powered by CNDBA · 皖ICP备2022006297号-1·

        QQ交流群

        注册联系QQ