containerops.cn/docker/registry
#!/usr/bin/env bash
#Usage docker-machine-update-hosts.sh hosts.conf default
#arg1 is a configuration file with hosts
#arg2 is the docker-machine name e.g. default
DOCKER_IP=$(docker-machine ip $2)
echo "$2 ip: $DOCKER_IP"
#Remove existing lines from hosts
while IFS='' read -r line || [[ -n "$line" ]]; do
echo "Removing existing domain $line"
sudo sed -i '' '/'$line'/d' /etc/hosts
done < "$1"
#Add new hosts to the bottom of the file
while IFS='' read -r line || [[ -n "$line" ]]; do
echo "Adding entry $DOCKER_IP $line"
sudo echo "$DOCKER_IP $line" >>/etc/hosts
done < "$1"
Put this line before your rpm -i command:
ADD /host/abs/path/to/chrpath-0.13-14.el7.x86_64.rpm /chrpath-0.13-14.el7.x86_64.rpm
Then you’ll be able to do
RUN rpm -i chrpath-0.13-14.el7.x86_64.rpm
docker-machine env default
sudo -i
sudo usermod -aG docker hadoop(username)
systemctl enable docker
运行仓库并命名为docker-registry,让镜像存储在宿主机上的/opt/docker/registry/data/
下
sudo docker run -d -p 5000:5000 -v /opt/docker/registry/data:/tmp/registry-dev --name docker-registry registry:2.0.1
sudo openssl req -x509 -nodes -newkey rsa:2048 -keyout /opt/docker/registry/conf/docker-registry.key -out /opt/docker/registry/conf/docker-registry.crt
为了让允许的用户登录访问,需要利用htpasswd创建用户和密码,并存储于/opt/docker/registry/conf/docker-registry.htpasswd文件.
sudo yum install httpd-tools -y
sudo htpasswd -c /opt/docker/registry/conf/docker-registry.htpasswd xl
第一个用户需要加-c参数,随后输入密码并确认。添加新用户不需要加-c参数。 例如:创建第二个用户
sudo htpasswd /opt/docker/registry/conf/docker-registry.htpasswd testu
sudo docker run -d -p 443:443 -e REGISTRY_HOST="docker-registry" -e REGISTRY_PORT="5000" -e SERVER_NAME="localhost" --link docker-registry:docker-registry -v /opt/docker/registry/conf/docker-registry.htpasswd:/etc/nginx/.htpasswd:ro -v /opt/docker/registry/conf:/etc/nginx/ssl:ro --name docker-registry-proxy containersol/docker-registry-proxy
ENV <key> <value> # 只能设置一个变量
ENV <key>=<value> ... # 允许一次设置多个变量
ENTRYPOINT [“executable”, “param1”, “param2”] (the preferred exec form,优先选择)
ENTRYPOINT command param1 param2 (shell form)
VOLUME ["/data"]
WORKDIR /path/to/workdir
docker tag 5db5f8471261 ouruser/sinatra:devel
docker tag tianon/centos localhost:5000/pip/centos
再 push
docker push localhost:5000/pip/centos
docker pull nginx
docker run -d -p 8080:80 ngnix
get vm ip address by " docker-machine ls"
http://host-ip:8080
yum install openssh-server openssh-clients
service sshd start
chkconfig sshd on
ssh localhost
user: docker
pass: tcuser
docker run -d -p 5000:5000 --restart=always --name registry registry:2
docker pull ubuntu && docker tag ubuntu localhost:5000/ubuntu
docker push localhost:5000/ubuntu
docker pull localhost:5000/ubuntu
docker run -d -p 5000:5000 --restart=always --name registry \
-v `pwd`/data:/var/lib/registry \
registry:2
(systemctl show docker | grep EnvironmentFile
systemctl status docker | grep Loaded)
vi /etc/default/docker
DOCKER_OPTS="--insecure-registry pip-dev:5000 --dns 8.8.8.8 --dns 192.168.0.1"
vi /usr/lib/systemd/system/docker.service
add
EnvironmentFile=-/etc/default/docker