这里的系统版本是debian8.8,harbor版本为1.1.2。
1、安装docker-ce
1.1、Install packages to allow apt to use a repository over HTTPS:
# apt-get install
apt-transport-https
ca-certificates
curl
gnupg2
software-properties-common
1.2、Add Docker’s official GPG key:
# curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -
1.3、Set up the stable repository:
# add-apt-repository
"deb [arch=amd64] https://download.docker.com/linux/debian
$(lsb_release -cs)
stable"
1.4、Install Docker-ce
# aptitude update
# aptitude install -y docker-ce
The Docker daemon starts automatically.
1.5、查看docker日志
# journalctl -u docker.service -f
2、安装docker-compose
# curl -L "https://github.com/docker/compose/releases/download/1.13.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/bin/docker-compose
# chmod +x /usr/bin/docker-compose
3、安装docker-compose补全工具
# curl -L https://raw.githubusercontent.com/docker/compose/$(docker-compose version --short)/contrib/completion/bash/docker-compose -o /etc/bash_completion.d/docker-compose
docker-compose的常用选项:
# docker-compose --help
Define and run multi-container applications with Docker.
docker-compose [-f <arg>...] [options] [COMMAND] [ARGS...]
-f, --file FILE:Specify an alternate compose file (default: docker-compose.yml)
down Stop and remove containers, networks, images, and volumes
exec Execute a command in a running container
help Get help on a command
images List images
kill Kill containers
logs View output from containers
port Print the public port for a port binding
ps List containers
pull Pull service images
push Push service images
restart Restart services
rm Remove stopped containers
scale Set number of containers for a service
start Start services
stop Stop services
top Display the running processes
up Create and start containers
version Show the Docker-Compose version information
4、安装harbor
# cd /usr/local/
# wget https://github.com/vmware/harbor/releases/download/v1.1.2/harbor-online-installer-v1.1.2.tgz
# tar xvf harbor-online-installer-v1.1.2.tgz
# cd harbor/
# vim harbor.cfg #修改hostname和密码。
# ./install.sh
安装完成后启动的容器:
/usr/local/harbor# docker-compose ps
Name Command State Ports
--------------------------------------------------------------------------------------------------------------------------------
harbor-adminserver /harbor/harbor_adminserver Up
harbor-db docker-entrypoint.sh mysqld Up 3306/tcp
harbor-jobservice /harbor/harbor_jobservice Up
harbor-log /bin/sh -c crond && rm -f ... Up 127.0.0.1:1514->514/tcp
harbor-ui /harbor/harbor_ui Up
nginx nginx -g daemon off; Up 0.0.0.0:443->443/tcp, 0.0.0.0:4443->4443/tcp, 0.0.0.0:8888->80/tcp
registry /entrypoint.sh serve /etc/ ... Up 5000/tcp
5、用浏览器访问server IP,默认监听80端口。
默认账号密码为:admin / Harbor12345
6、添加 --insecure-registry 启动参数。这里跟之前用的centos有点不同,感觉踩到坑,方法如下:
# vim /etc/default/docker
OPTIONS="--insecure-registry=10.90.5.105:8888" #注意这里,把默认的DOCKER_OPTS改成OPTIONS了
# vim /lib/systemd/system/docker.service
[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
EnvironmentFile=-/etc/default/docker #添加这一行,读取环境配置文件
ExecStart=/usr/bin/dockerd -H fd:// $OPTIONS #添加 $OPTIONS
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=1048576
# systemctl daemon-reload
# systemctl restart docker
# ps -ef | grep docker
root 5654 1 0 Jun15 ? 00:05:12 /usr/bin/dockerd -H fd:// --insecure-registry=10.90.5.105:8888
root 5659 5654 0 Jun15 ? 00:02:24 docker-containerd -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --metrics-interval=0 --start-timeout 2m --state-dir /var/run/docker/libcontainerd/containerd --shim docker-containerd-shim --runtime docker-runc
root 14459 14373 0 10:15 pts/0 00:00:00 grep --color docker