*查看docker镜像仓库
sudo docker images
*搜索docker镜像
sudo docker search ubuntu
*拉取docker镜像文件
sudo docker pull ubuntu
*运行镜像文件,并进入root终端
sudo docker run -i -t ubuntu bash
#apt-get update
#apt-get install git
#git clone https://github.com/wufeifei/cobra.git
#cd cobra/
------------------------------------------------------------------------
ubuntu:
apt-get update
apt-get install python2.7-dev
apt-get install python-pip
apt-get install mysql-server mysql-client
apt-get install gcc-c++
apt-get install python-mysqldb
apt-get install cloc
cenos:
# Python
[sudo] yum install Python-devel
# MySQL
[sudo] yum install MySQL-python
[sudo] yum install mysql-devel
# PIP
[sudo] yum install epel-release
[sudo] yum install python-pip
# gcc-c++
[sudo] yum install gcc-c++
# Cloc (任选其一)
npm install -g cloc # https://www.npmjs.com/package/cloc
sudo apt-get install cloc # Debian, Ubuntu
sudo yum install cloc # Red Hat, Fedora
sudo pacman -S cloc # Arch
sudo pkg install cloc # FreeBSD
sudo port install cloc # Mac OS X with MacPorts
------------------------------------------------------------------------
额外安装(如果在Mac OS X下)
# grep(gnu)
brew install homebrew/dupes/grep
# find(gnu)
brew install findutils
安装Cobra的Python依赖
# Cobra根目录下
pip install --upgrade pip
[sudo] pip install -r requirements.txt
配置Cobra(Cobra配置方法)
mysql> update mysql.user set authentication_string=password('new_password') where user='root' and Host ='localhost';
mysql> flush privileges;
mysql> quit;
GBK: create database cobra DEFAULT CHARACTER SET gbk COLLATE gbk_chinese_ci;
UTF8: CREATE DATABASE `cobra` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
cp config.example config
vim config
初始化数据库表结构和数据
python cobra.py install
启动Cobra
python cobra.py start &
日志信息
tail -f logs/cobra.log
*查看容器ip
sudo docker inspect da8609d69f7d
*给运行中的容器,添加端口映射;把80端口映射到主机的8000端口
docker run -d -p 8000:80 cobra /bin/bash
*查看运行过的docker
sudo docker ps -a
*保存操作过的容器为镜像
sudo docker commit da8609d69f7d cobra
*查看是否已保存
sudo docker images
*对于 run 命令可以使用 -it 参数进入 bash 来 -d保持容器后台运行
$docker run -d -i -t -p 5000:5000 cobra /bin/bash
*直接进入容器终端
docker attach 2aadecbc816f
*vim Dockerfile
FROM cobra
ADD mysite.tar /tmp/
RUN mv /tmp/mysite/* /var/www/html
EXPOSE 5000
CMD ["/root/start.sh"]
*生成新的镜像,退出时删除
docker build -rm -t mysite