首页 技术 正文
技术 2022年11月19日
0 收藏 781 点赞 2,640 浏览 2328 个字

标签(linux): docker

笔者Q:972581034 交流群:605799367。有任何疑问可与笔者或加群交流

环境准备

[root@docker ~]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
[root@docker ~]# free -h
total used free shared buff/cache available
Mem: 1.8G 209M 517M 8.9M 1.1G 1.3G
Swap: 1.0G 0B 1.0G
[root@docker ~]# hostname -I
10.0.0.250 172.16.1.250
systemctl disable firewalld.service
systemctl stop firewalld.service
iptables -F

安装yum-utils,它提供yum-config-manager实用程序

yum install -y yum-utils

添加稳定版本库

yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo

更新yum包索引

yum makecache fast

安装Docker社区版

yum install docker-ce -y

启动docker守护进程

systemctl enable docker
systemctl start docker
systemctl status docker

测试,,,网络延时问题可能会导致测试不成功,多测两次

docker run hello-world

查看镜像

c7是下面要用来启动容器的镜像,在centos镜像的基础上安装了常用软件包。

[root@docker ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
c7 latest 8af948261786 2 days ago 476 MB
centos latest a8493f5f50ff 6 weeks ago 192 MB

这里需要一些相关的软件包和配置文件,这里给大家提供了链接:http://pan.baidu.com/s/1eR8vdXg 密码:l1sj

创建web01

docker run --network=host -itd  --name=web01 -h web01 c7
docker attach web01

使用提供的软件包安装nginx

#nginx
yum localinstall -y nginx-1.10.2-1.x86_64.rpm

nginx配置文件

cd /application/nginx/conf/[root@web01 conf]# cat nginx.conf
worker_processes  1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
include extra/blog.conf;
}
[root@web01 conf]# mkdir extra
[root@web01 extra]# ls
blog.conf

上传wordpress到站点根目录

[root@web01 extra]# cd /application/nginx/html/
[root@web01 html]# wget https://cn.wordpress.org/wordpress-4.7.4-zh_CN.tar.gz
[root@web01 html]# tar xf wordpress-4.7.4-zh_CN.tar.gz
[root@web01 html]# chown -R www.www /application/nginx/html

启动nginx,安装php并启动

/application/nginx/sbin/nginx
chmod +x /etc/rc.local
echo "/application/nginx/sbin/nginx" >> /etc/rc.local#php
yum localinstall libiconv-devel-1.15-1.x86_64.rpm php-5.5.32-1.x86_64.rpm -y
/application/php/sbin/php-fpm
chmod +x /etc/rc.local
echo "/application/php/sbin/php-fpm" >> /etc/rc.local

创建数据库容器

docker run --network=host -itd  --name=db01 -h db01 c7
docker attach db01

安装并启动数据库

yum -y install mariadb mariadb-server
mysql_install_db --user=mysql
mysqld_safe &>/dev/null &
/usr/bin/mysqladmin -u root password '123456'
mysql -uroot -p123456

创建wordpress库和授权帐户

create database wordpress;
grant all on wordpress.* to 'wordpress'@'localhost' identified by '123456';
grant all on wordpress.* to wordpress@'172.16.1.250' identified by '123456';

登录浏览器测试

来个美女养养眼

docker常用命令

http://www.cnblogs.com/Csir/p/6888474.html

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,086
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,561
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,410
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,183
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,820
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,903