Docker-wordpress

#参考:《docker经典实例》
#如有侵权请联系我我会尽快删除
#docker下拉wordpress程序
docker pull wordpress
#docker下拉mysql程序
docker pull mysql

#查看已有的docker容器
docker images


#在后台运行名字为mysqlwp的mysql程序,密码设置为wordpressdocker
docker run --name mysqlwp -e MYSQL_ROOT_PASSWORD=wordpressdocker -d mysql
#在后台运行名字为wordpress的wordpres程序,数据库mysql链接mysqlws,端口80映射到主机
docker run --name wordpress --link mysqlwp:mysql -p 80:80 -d wordpress

docker run --name mysqlwp -e MYSQL_ROOT_PASSWORD=wordpressdocker -e MYQSL_DATABASE=wordpress -e MYSQL_USER=wordpress -e MYSQL_PASSWORD=wordpresspwd -d mysql

docker stop $(docker ps -q)

docker rm  -v $(docker ps -qa)

docker run --bane wordpress --link mysqlwp:mysql -p 80:80 -e WORDPRESS_DB_NAME=wordpress -e WORDPRESS_DB_USER=wordpress -e WORDPRESS_DB_PASSWORD=wordpresspwd -d wordpress

docker run --name mysqlwp -e MYSQL_ROOT_PASSWORD=wordpressdocker -e MYSQL_DATABASE=wordpress -e MYSQL_USER=wordpress -e MYSQL_PASSWORD=wordpresspwd -v /home/docker/mysql:/var/lib/mysql -d mysql

docker exec mysqlwp mysqldump --all-database --password=wordpressdocker > wordpress.sql.backup

docker run -ti -v "$PWD":/cookbook ubuntu:14.04 /bin/bash

##
-v "$PWD":/cookbook:ro
##
#查看数据卷挂载状态
docker inspect -f {{.Mounts}}  dockername

docker run -ti -v /cookbook ubuntu:14.04 /bin/bash

docker inspect -f {{.Mounts}} dockername

docker run -v /data --name data ubuntu;14.04

docker ps -a

docker inspect -f {{.Mounts}} dockername

docker rm -v data

docker run -ti --volumes-from data ubuntu:14.04 /bin/bash


docker cp

docker run -d --name testcopy ubuntu:14.04 sleep 360

docker exec -ti testcopy /bin/bash

docker cp testcopy:/root/file.txt  .

docker cp hosts.txt testcopy:/root/hosts.txt

docker cp c1:/root/file.txt .

docker file.txt c2:/root/file.txt


docker exec -i testcopy sh -c 'cat > /root/hosts.txt' < host.txt

docker exec -i textcopy sh -c 'cat /root/host.txt'

dockerrun -t -n dockercommit -i ubuutn:14.04 /bin/bash

docker commit dockercommit ubuntu:update

docker images

docker diff dockercommit

docker ps -a

docker import - update < update.tar
docker images

docker save -o update1.tar update

docker rmi update

docker load < update1.tar

docker images

touch Dockerfile

vim Dockerfile

FROM ubuntu:14.04
ENTRYOINT ["/bin/echo"]

docker build .

docker images

docker run dockerimage Hi Docker!

docker run dockerimage

touch Dockerfile

vim Dockerfile
FROM ubuntu:14.04
CMD  ['/bin/echo', 'Hi Docker !']

docker build .

docker run dokcerimage

docker run dockerimage /bin/date

docker build -t cookbook:hello .

docker images

docker build -h







#查看所有本地的docker容器
docker ps -a

########################################
#以下并没有实际操作
touch Dockerfile

vim Dockerfile

FROM ubuntu:14.04
RUN apt update -y
RUN apt upgrade -y
RUN apt install apache2 php php-mysql supervisor wget -y

RUN echo 'mysql-server mysql-server/root_password password root' | debconf-set-selections && echo 'mysql-server mysql-server/root_password_again password root' | debconf-set-selections

RUN apt install -y mariadb mariadb-server

RUN wget http://wordpress.org/latest.tar.gz && tar -zxvf lastest.tar.gz && cp -a ./wordpress/* /var/www/html && rm -rf /var/www/html/index.html

RUN (/usr/bin/mysqld_safe &);sleep 5
RUN mysqladmin -u root -proot create wordpress
COPY wp-config.php /var/www/html/wp-config.php
COPY supervidord.conf /etc/supervisor/conf.d/supervisord.conf
EXPOSE 80
CMD ['/usr/bin/supervisord']


touch supervisord.conf
vim supervidord.conf

[supervidord]
noaemon=true

[program:mysqld]
command=/usr/bin/mysqld_safe
autostart=true
autorestart=true
user=root

[program:httpd]
command=/bin/bash -c "rm -rf /run/httpd/* && /usr/sbin/apachectl -D FOREGOUND "

cd /vagrant

docker build -t wordpress.
docker run -d -p 80:80 wordpress

##############################################