docker 镜像制作

# wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-5.3.1-Linux-x86_64.sh
# bash Anaconda3-5.3.1-Linux-x86_64.sh

# source ~/.bashrc
# conda -V

# conda install jupyter notebook
# jupyter notebook
# conda install ipython

# ipython 进入python shell交互

# jupyter notebook --generate-config
Writing default config to: /root/.jupyter/jupyter_notebook_config.py

# ipython //进入ipython交互模式
# In [1]: from notebook.auth import passwd
# In [2]: passwd()

Enter password:
Verify password:
Out[2]: 'sha1:d93397e8cfba:d93d88814530642f44233b72110621aef924bdd7'

'sha1:97fb8b9cfed6:bd105748f3ce5f9ec1ff7eb21c43f00019c6ba6f'

修改默认配置文件

# vi ~/.jupyter/jupyter_notebook_config.py

c.NotebookApp.ip='*' # 设置所有ip皆可访问
c.NotebookApp.password = u'sha1:上面生成的哈希值' #
c.NotebookApp.open_browser = False # 禁止自动打开浏览器
c.NotebookApp.port = 8888 #指定一个端口
更改存储文件地址
## The directory to use for notebooks and kernels.
2 c.NotebookApp.notebook_dir = 'E:devJupyter'

启动jupyter

# jupyter notebook --allow-root

启动脚本 auto_service.sh

#!/bin/sh
/bin/serviceA start #启动服务
/bin/bash #保留一个终端,防止容器自动退出 

启动镜像按指定启动脚本 

docker run -d -t -v /etc/localtime:/etc/localtime -p 8889:8889  --name service_A imageX   /home/auto_service.sh

登录和提交镜像

docker pull centos
docker run -it -d --name test-centos1 centos
docker exec -it test-centos1 /bin/bash
docker commit test-centos1 centos_sshd:7.0

conda install -c anaconda pymysql
from sqlalchemy import create_engine
engine=create_engine('mysql+pymysql://username:password.@HOST_IP:PORT/db_name?charset=utf8') 
conn = engine.connect() 
r = conn.execute('select sysdate()')
查看 centos version
 cat /etc/redhat-release

 linux 离线安装缺少包可强制安装
rpm -ivh  --nodeps  createrepo-0.9.9-28.el7.noarch.rpm #意思不考虑依赖

centos1
docker exec -it 93b7ef3dd8f8 /bin/bash 172.31.254.3
creditapp
docker exec -it 9999d669359a /bin/bash 172.31.254.7
xxl-job
docker exec -it 05f5424f45a4 /bin/bash 172.31.254.6
docker cp ./ROOT 05f5424f45a4:/usr/local/tomcat/webapps/ROOT
fastdfs
172.31.254.8
从服务器下载整个目录
scp -r root@172.96.190.155:/data/ROOT/ ./
docker cp /data/bak/ROOT 93b7ef3dd8f8:/data

注释:

--privileged=true  #特权模式

--restart=always #容器随docker 服务启动

重新加载配置

/sbin/service crond reload

重启cron

/sbin/service crond restart

wq退出

[root@localhost ~]# crontab -r   删除任务

[root@localhost ~]# crontab -l    显示任务

 特权模式进入容器:
# docker run -d -name centos7 --privileged=true centos:7 /usr/sbin/init

导入导出镜像
导出镜像
docker save efb6dd7c8649 > test-save.tar
docker load < test-save.tar