docker入门
1.配置yum软件库
为保证安装的成功,首先使用yum update
更新yum包,表示我的好多yum包都需要更新,1500+的包,如果你像我一样好久没有更新过,那就耐心等候吧。
然后在yum软件库中新增docker的配置:
# tee /etc/yum.repos.d/docker.repo <<-'EOF'
[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/7/
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg
EOF
2.安装Docker
有了yum软件库的配置之后,安装也变得异常的简单,只需要以下一句即可:
# yum install docker-engine
3.启动Docker
一切就绪之后,使用start命令来启动Docker守护进程:
# service docker start
4.输出hello-world
程序员貌似跟hello-world有仇,有事儿没事就打印人家一下,玩docker咱们当前也不例外,先来个hello-world吧,这里的基本原理是利用人家已经写好的hello-world镜像,下载到本地,然后把他运行起来~
使用以下命令:
# docker run hello-world
参考网址:http://www.cnblogs.com/baiyunchen/p/5716617.html
官网文档:https://docs.docker.com/engine/installation/linux/centos/
推荐书籍
《Docker技术入门与实战》
windows 安装docker toolbox
1、配置 Docker 加速器
docker-machine ssh default
sudo sed -i "s|EXTRA_ARGS='|EXTRA_ARGS='--registry-mirror=https://a4nc0je0.mirror.aliyuncs.com |g" /var/lib/boot2docker/profile
exit
docker-machine restart default
2、拷贝文件到容器内
docker cp /usr/tomcat/jdk-8u111-linux-x64.rpm ice1:/root
ice1为容器名称
如何提高docker下载速度
采用daoclould
网址如下:
https://www.daocloud.io/mirror#accelerator-doc
not connect to the Docker daemon. Is the docker daemon running on this host?
是因为没有开启docker服务
删除悬挂镜像:
docker images -f dangling=true//列出悬挂镜像
docker rmi $(docker images -q -f dangling=true)
停止镜像
提交镜像
Dockerfile创建第一个tomcat运行环境
FROM ubuntu
COPY tomcat8 /usr/tomcat8
ADD jdk-8u111-linux-x64.tar.gz /usr/
RUN mv /usr/jdk1.8.0_111 /usr/jdk8
CMD /usr/tomcat8/bin/startup.sh && tail -f /usr/tomcat8/logs/catalina.out
Ubuntu问题汇总
ubuntu如何更新软件源
rm /etc/apt/sources.list
touch /etc/apt/sources.list
//换为阿里的软件源
sudo echo "deb http://mirrors.aliyun.com/ubuntu/ trusty main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main multiverse restricted universe" | >>/etc/apt/sources.list
批量删除
docker rmi -f $(docker images | grep -v TAG | awk '$1=="tomcat" {print "tomcat:" $2}')
echo “hello” > test.txt 覆写
echo "hello" >> 追加
CentOS问题汇总
Ctrl+U 向前删除直到行首
Ctrl+L清屏