- 浏览: 2551012 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
nation:
你好,在部署Mesos+Spark的运行环境时,出现一个现象, ...
Spark(4)Deal with Mesos -
sillycat:
AMAZON Relatedhttps://www.godad ...
AMAZON API Gateway(2)Client Side SSL with NGINX -
sillycat:
sudo usermod -aG docker ec2-use ...
Docker and VirtualBox(1)Set up Shared Disk for Virtual Box -
sillycat:
Every Half an Hour30 * * * * /u ...
Build Home NAS(3)Data Redundancy -
sillycat:
3 List the Cron Job I Have>c ...
Build Home NAS(3)Data Redundancy
Docker(2)Repositories and PHP example on CentOS
1. Repositories
for example, dl.dockerpool.com/ubuntu, dl.dockerpool.com is a registry server, ubuntu is the repository name.
Here is my private repo
https://registry.hub.docker.com/u/sillycat/machinelearning/
Here is my public repo
https://registry.hub.docker.com/u/sillycat/public/
Login the docker hub
> sudo docker login
Username: sillycat
Password:
Email: luohuazju@gmail.com
Login Succeeded
The information will be stored here
> sudo vi ~/.dockercfg
Build the image
> sudo docker build -t="sillycat/public" .
List the info
> sudo docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
sillycat/public latest 8800fd804e5c About a minute ago 301 MB
This will push the images to my repo
> sudo docker push sillycat/public
Pull the images
> sudo docker pull sillycat/public
For private repo with tag
> sudo docker build -t="sillycat/machinelearning:v1.0" .
> sudo docker push sillycat/machinelearning
> sudo docker pull sillycat/machinelearning:v1.0
2. Example to Build PHP Env on CentOS
Pull the images
> sudo docker pull centos
Start the container for trying purpose
> sudo docker run -t -i centos:7 /bin/bash
Build the Image for PHP
> sudo docker build -t sillycat/public:centos7-php .
Remove the images with their IMAGE ID
> sudo docker rmi -f 70f8f9ad6d7f
List the current running containers
> sudo docker ps
Stop the container by their names
> sudo docker stop grave_morse
Check the IP address for a container
> sudo docker inspect --format '{{ .NetworkSettings.IPAddress }}' centos7-php
Inspect all the data for one container
> sudo docker inspect centos7-nginx
Introduce some key things in sillycat-docker project
for centos7-php
We have a docker file Dockerfile, the content will be something like this:
FROM centos:7
#PHP 5.6.10 and PHP-FPM
RUN rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
RUN rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
RUN yum install -y php56w php56w-fpm
RUN yum install -y telnet
# Add in the php fpm configuration
ADD www.conf /etc/php-fpm.d/
#Prepare the Content
RUN mkdir -p /app/htdocs
ADD htdocs/ /app/htdocs/
#VOLUME /app/htdocs
#Prepare the shell
ADD start.sh /app/
#excute the shell
CMD /app/start.sh
This will prepare the system, pre-install a lot of software for me and copy the binary to work directory and start the application at last.
The start.sh will be just simple command to start the php-fpm
#!/bin/sh -ex
php-fpm --nodaemonize
The most import part to make www.conf work for php-fpm is the listen configuration
; The address on which to accept FastCGI requests.
; Valid syntaxes are:
; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific address on
; a specific port;
; 'port' - to listen on a TCP socket to all addresses on a
; specific port;
; '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
listen=9000
It will listen to all the client IP addresses.
Under the htdocs/index.php, it is just a really simple hello word.
<?php
echo "Hello, sillycat!\n\n\n";
phpinfo();
?>
And the Makefile Command file really help me, it is hard to remember all the options and command in docker,
IMAGE=sillycat/public
TAG=centos7-php
NAME=centos7-php
docker-context:
build: docker-context
sudo docker build -t $(IMAGE):$(TAG) .
run:
sudo docker run -d --name $(NAME) $(IMAGE):$(TAG)
run-volume:
sudo docker run -d --name $(NAME) -v $(shell pwd)/htdocs:/app/htdocs:ro $(IMAGE):$(TAG)
# docker run -ti --name $(NAME) -v $(shell pwd)/htdocs:/app/htdocs:ro $(IMAGE):$(TAG) /bin/bash
debug:
sudo docker run -ti --name $(NAME) $(IMAGE):$(TAG) /bin/bash
clean:
sudo docker stop ${NAME}
sudo docker rm ${NAME}
logs:
sudo docker logs ${NAME}
publish:
sudo docker push ${IMAGE}
These command will do the build, run, debug and clean publish.
> make build
> make publish
Little new things for nginx to running on docker
php-fpm.conf
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root /app/htdocs;
fastcgi_pass centos7-php:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
Dockerfile
#fetch and pick the OS first
FROM centos:7
#Install nginx
RUN yum install -y epel-release
RUN yum install -y nginx
RUN yum install -y telnet
EXPOSE 80
ADD php-fpm.conf /etc/nginx/default.d/
RUN mkdir -p /app/
ADD start.sh /app/
CMD /app/start.sh
Then we can visit this page URLs to verify
http://ubuntu-pilot:8080/index.php
http://ubuntu-pilot:8080
May read more things on VOLUME and WORKDIR in the future.
Compile and Run on Dockerfile is working as well.
#fetch and pick the OS first
FROM centos:7
#prepare build env
RUN yum install -y wget gcc make
#prepare libraries for nginx
RUN yum install -y zlib-devel pcre-devel
#download resource and build and install nginx
RUN mkdir /install/
WORKDIR /install/
RUN wget http://nginx.org/download/nginx-1.9.2.tar.gz
RUN tar zxvf nginx-1.9.2.tar.gz
WORKDIR /install/nginx-1.9.2
RUN ./configure --prefix=/tool/nginx-1.9.2
RUN make && make install
EXPOSE 80
ADD nginx.conf /tool/nginx-1.9.2/conf/
RUN mkdir -p /app/
ADD start.sh /app/
CMD /app/start.sh
References:
http://sillycat.iteye.com/blog/2223733
http://dockerpool.com/static/books/docker_practice/repository/README.html
http://blog.arungupta.me/pushing-docker-images-registry-techtip58/
1. Repositories
for example, dl.dockerpool.com/ubuntu, dl.dockerpool.com is a registry server, ubuntu is the repository name.
Here is my private repo
https://registry.hub.docker.com/u/sillycat/machinelearning/
Here is my public repo
https://registry.hub.docker.com/u/sillycat/public/
Login the docker hub
> sudo docker login
Username: sillycat
Password:
Email: luohuazju@gmail.com
Login Succeeded
The information will be stored here
> sudo vi ~/.dockercfg
Build the image
> sudo docker build -t="sillycat/public" .
List the info
> sudo docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
sillycat/public latest 8800fd804e5c About a minute ago 301 MB
This will push the images to my repo
> sudo docker push sillycat/public
Pull the images
> sudo docker pull sillycat/public
For private repo with tag
> sudo docker build -t="sillycat/machinelearning:v1.0" .
> sudo docker push sillycat/machinelearning
> sudo docker pull sillycat/machinelearning:v1.0
2. Example to Build PHP Env on CentOS
Pull the images
> sudo docker pull centos
Start the container for trying purpose
> sudo docker run -t -i centos:7 /bin/bash
Build the Image for PHP
> sudo docker build -t sillycat/public:centos7-php .
Remove the images with their IMAGE ID
> sudo docker rmi -f 70f8f9ad6d7f
List the current running containers
> sudo docker ps
Stop the container by their names
> sudo docker stop grave_morse
Check the IP address for a container
> sudo docker inspect --format '{{ .NetworkSettings.IPAddress }}' centos7-php
Inspect all the data for one container
> sudo docker inspect centos7-nginx
Introduce some key things in sillycat-docker project
for centos7-php
We have a docker file Dockerfile, the content will be something like this:
FROM centos:7
#PHP 5.6.10 and PHP-FPM
RUN rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
RUN rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
RUN yum install -y php56w php56w-fpm
RUN yum install -y telnet
# Add in the php fpm configuration
ADD www.conf /etc/php-fpm.d/
#Prepare the Content
RUN mkdir -p /app/htdocs
ADD htdocs/ /app/htdocs/
#VOLUME /app/htdocs
#Prepare the shell
ADD start.sh /app/
#excute the shell
CMD /app/start.sh
This will prepare the system, pre-install a lot of software for me and copy the binary to work directory and start the application at last.
The start.sh will be just simple command to start the php-fpm
#!/bin/sh -ex
php-fpm --nodaemonize
The most import part to make www.conf work for php-fpm is the listen configuration
; The address on which to accept FastCGI requests.
; Valid syntaxes are:
; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific address on
; a specific port;
; 'port' - to listen on a TCP socket to all addresses on a
; specific port;
; '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
listen=9000
It will listen to all the client IP addresses.
Under the htdocs/index.php, it is just a really simple hello word.
<?php
echo "Hello, sillycat!\n\n\n";
phpinfo();
?>
And the Makefile Command file really help me, it is hard to remember all the options and command in docker,
IMAGE=sillycat/public
TAG=centos7-php
NAME=centos7-php
docker-context:
build: docker-context
sudo docker build -t $(IMAGE):$(TAG) .
run:
sudo docker run -d --name $(NAME) $(IMAGE):$(TAG)
run-volume:
sudo docker run -d --name $(NAME) -v $(shell pwd)/htdocs:/app/htdocs:ro $(IMAGE):$(TAG)
# docker run -ti --name $(NAME) -v $(shell pwd)/htdocs:/app/htdocs:ro $(IMAGE):$(TAG) /bin/bash
debug:
sudo docker run -ti --name $(NAME) $(IMAGE):$(TAG) /bin/bash
clean:
sudo docker stop ${NAME}
sudo docker rm ${NAME}
logs:
sudo docker logs ${NAME}
publish:
sudo docker push ${IMAGE}
These command will do the build, run, debug and clean publish.
> make build
> make publish
Little new things for nginx to running on docker
php-fpm.conf
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root /app/htdocs;
fastcgi_pass centos7-php:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
Dockerfile
#fetch and pick the OS first
FROM centos:7
#Install nginx
RUN yum install -y epel-release
RUN yum install -y nginx
RUN yum install -y telnet
EXPOSE 80
ADD php-fpm.conf /etc/nginx/default.d/
RUN mkdir -p /app/
ADD start.sh /app/
CMD /app/start.sh
Then we can visit this page URLs to verify
http://ubuntu-pilot:8080/index.php
http://ubuntu-pilot:8080
May read more things on VOLUME and WORKDIR in the future.
Compile and Run on Dockerfile is working as well.
#fetch and pick the OS first
FROM centos:7
#prepare build env
RUN yum install -y wget gcc make
#prepare libraries for nginx
RUN yum install -y zlib-devel pcre-devel
#download resource and build and install nginx
RUN mkdir /install/
WORKDIR /install/
RUN wget http://nginx.org/download/nginx-1.9.2.tar.gz
RUN tar zxvf nginx-1.9.2.tar.gz
WORKDIR /install/nginx-1.9.2
RUN ./configure --prefix=/tool/nginx-1.9.2
RUN make && make install
EXPOSE 80
ADD nginx.conf /tool/nginx-1.9.2/conf/
RUN mkdir -p /app/
ADD start.sh /app/
CMD /app/start.sh
References:
http://sillycat.iteye.com/blog/2223733
http://dockerpool.com/static/books/docker_practice/repository/README.html
http://blog.arungupta.me/pushing-docker-images-registry-techtip58/
发表评论
-
Update Site will come soon
2021-06-02 04:10 1677I am still keep notes my tech n ... -
Stop Update Here
2020-04-28 09:00 315I will stop update here, and mo ... -
NodeJS12 and Zlib
2020-04-01 07:44 475NodeJS12 and Zlib It works as ... -
Docker Swarm 2020(2)Docker Swarm and Portainer
2020-03-31 23:18 367Docker Swarm 2020(2)Docker Swar ... -
Docker Swarm 2020(1)Simply Install and Use Swarm
2020-03-31 07:58 368Docker Swarm 2020(1)Simply Inst ... -
Traefik 2020(1)Introduction and Installation
2020-03-29 13:52 335Traefik 2020(1)Introduction and ... -
Portainer 2020(4)Deploy Nginx and Others
2020-03-20 12:06 429Portainer 2020(4)Deploy Nginx a ... -
Private Registry 2020(1)No auth in registry Nginx AUTH for UI
2020-03-18 00:56 435Private Registry 2020(1)No auth ... -
Docker Compose 2020(1)Installation and Basic
2020-03-15 08:10 373Docker Compose 2020(1)Installat ... -
VPN Server 2020(2)Docker on CentOS in Ubuntu
2020-03-02 08:04 454VPN Server 2020(2)Docker on Cen ... -
Buffer in NodeJS 12 and NodeJS 8
2020-02-25 06:43 384Buffer in NodeJS 12 and NodeJS ... -
NodeJS ENV Similar to JENV and PyENV
2020-02-25 05:14 475NodeJS ENV Similar to JENV and ... -
Prometheus HA 2020(3)AlertManager Cluster
2020-02-24 01:47 421Prometheus HA 2020(3)AlertManag ... -
Serverless with NodeJS and TencentCloud 2020(5)CRON and Settings
2020-02-24 01:46 336Serverless with NodeJS and Tenc ... -
GraphQL 2019(3)Connect to MySQL
2020-02-24 01:48 246GraphQL 2019(3)Connect to MySQL ... -
GraphQL 2019(2)GraphQL and Deploy to Tencent Cloud
2020-02-24 01:48 450GraphQL 2019(2)GraphQL and Depl ... -
GraphQL 2019(1)Apollo Basic
2020-02-19 01:36 326GraphQL 2019(1)Apollo Basic Cl ... -
Serverless with NodeJS and TencentCloud 2020(4)Multiple Handlers and Running wit
2020-02-19 01:19 312Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(3)Build Tree and Traverse Tree
2020-02-19 01:19 317Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(2)Trigger SCF in SCF
2020-02-19 01:18 292Serverless with NodeJS and Tenc ...
相关推荐
离线环境下,在centos7.6系统上安装docker-ce-19.03,nvidia-docker2.4版本,其中docker-ce-19.03在docker-local.tar压缩文件里面,nvidia-docker2在nvidia-docker2.zip文件中。 具体安装流程如下: 1.安装docker ...
在CentOS 7.6上离线安装Docker CE 19.03和Nvidia Docker 2可以按照以下步骤进行操作: 首先,您需要从Docker官方网站或Nvidia Docker官方网站下载对应版本的安装包。确保选择与您的操作系统和架构(例如x86_64)...
2. **上传到服务器**:将包含所有RPM包的压缩文件上传到你的CentOS 7服务器。可以使用FTP、SCP或其他文件传输工具完成这个步骤。 3. **解压并安装**:在服务器上找到你的压缩包位置,使用`unzip`或`tar`命令解压。...
【docker_centos7】docker在centos7中如何安装??.md【docker_centos7】docker在centos7中如何安装??.md【docker_centos7】docker在centos7中如何安装??.md【docker_centos7】docker在centos7中如何安装??.md
centos7 nvidia-docker2离线安装包,使用命令rpm -ivh --force *.rpm sudo systemctl restart docker sudo systemctl daemon-reload 依次执行此命令,如果 事先安装了containerd.io 则需要先进行 rpm -qa | grep ...
CentOS7 Docker Tar镜像,
在本文中,我们将深入探讨如何在CentOS 6.8系统上离线安装Docker环境,这主要依赖于RPM(Red Hat Package Manager)包。RPM是Linux发行版如CentOS用来安装、升级和管理软件的主要方式。由于是离线安装,我们需要预先...
使用Docker将镜像从一个主机迁移到另一个主机,可以使用以下命令:`docker save 镜像名 | bzip2 | ssh root@10.140.1.120 "cat | docker load"` 八、Docker解压镜像 使用Docker解压镜像可以使用以下命令:`docker ...
Centos 6.9安装docker步骤,同步部署。自己整理容器实用。
docker、docker_compose一键安装,适配CentOS、银河麒麟、统信UOS等。
2. 使用 Docker 可以创建基于 CentOS 的镜像文件。 3. 配置基本设置和端口是搭建容器的重要步骤。 4. 安装必要的软件包是搭建容器的重要步骤。 5. 更新所有程序是搭建容器的重要步骤。 6. 使用 `sed` 命令可以更新...
在基础镜像centos7.5的基础上,增加了vim,net-tools命令,及libnpg,gtk2系统库。
### CentOS7下Docker桥接网络配置详解 #### 一、背景介绍 Docker作为一种流行的容器化技术,为开发者提供了轻量级、可移植的容器环境。为了更好地管理容器之间的网络通信,理解Docker在网络配置方面的机制至关重要...
本离线安装资料包提供了在CentOS上安装NVIDIA-Docker2的步骤,尤其适合网络环境不稳定或者需要离线安装的场景。 首先,你需要确保系统已经安装了Docker。在CentOS中,可以通过以下步骤安装: 1. 更新系统软件包: ...
docker 24.06 centos7 离线安装包
CentOS6.7 Docker最小版镜像 最小版的CentOS6.7,安装了openssh、wget、vim、target,用户名:root/root
CentOS7 Docker防火墙的简单配置 禁用 firewalld 服务 systemctl disable firewalld systemctl stop firewalld 安装 iptables 防火墙服务 yum install iptables-services 创建 iptables 配置脚本 cat >> /usr/...
这个我亲手写的docker入门教程,适合入门者,欢迎下载。
安装步骤参考:https://blog.csdn.net/chkai123/article/details/126229727 docker离线安装 arm架构下离线安装docker docker centos7离线安装docekr 离线安装docker arm架构下安装docker arm架构centos7安装docker
Docker 安装 Oracle11g(CentOs)