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.shnode

# source ~/.bashrc
# conda -Vpython

# conda install jupyter notebook
# jupyter notebook
# conda install ipythonmysql

# ipython 進入python shell交互linux

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

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

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

'sha1:97fb8b9cfed6:bd105748f3ce5f9ec1ff7eb21c43f00019c6ba6f'shell

修改默認配置文件centos

# 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:\dev\Jupyter'

啓動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

 

導入導出鏡像

導出鏡像docker save efb6dd7c8649 > test-save.tar導入鏡像docker load < test-save.tar

相關文章
相關標籤/搜索