制作镜像并上传到阿里云
来源:互联网 发布:java编程思想 pdf 编辑:程序博客网 时间:2024/06/06 09:27
run一个ubuntu容器,然后自动进入容器
ucsmy@QKTEST21191:~$ docker run -it --name node daocloud.io/ubunturoot@3ac09729dadb:/#
安装geth
sudo apt-get install software-properties-commonsudo add-apt-repository -y ppa:ethereum/ethereumsudo apt-get updatesudo apt-get install ethereum
创建初始块mkdir privategeth && cd privategeth
root@3ac09729dadb:/privategeth# vi genesis.json{ "config": { "chainId": 12345, "homesteadBlock": 0, "eip155Block": 0, "eip158Block": 0 }, "coinbase" : "0x0000000000000000000000000000000000000000", "difficulty" : "0x400", "extraData" : "0x123456", "gasLimit" : "0xffffffff", "nonce" : "0x0000000000000042", "mixhash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "timestamp" : "0x00", "alloc": { }}
初始化并进入geth
root@3ac09729dadb:/privategeth# geth --datadir ./data init genesis.jsonroot@3ac09729dadb:/privategeth# geth --datadir ./data --networkid 12345 --rpc --port 3344 console 2>>geth.log Welcome to the Geth JavaScript console!instance: Geth/v1.6.7-stable-ab5646c5/linux-amd64/go1.8.1 modules: admin:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0
测试功能
personal.newAccount()Passphrase: Repeat passphrase: "0xbbe5e5a1e36f018975e99ba3044d448253755a4c"> > eth.getBalance(eth.accounts[0])45000000000000000000> > eth.blockNumber17
查看节点的信息
> admin.nodeInfo{ enode: "enode://23c31d1c3735bcc1a000c8fa271ddb1d74bdbed5d8172773b23c205cfbe2bd2c8d9441a1dddf15ed217b3db8bb319dbba98c0aba7168fb54f7d4ad48686756ae@[::]:3344", id: "23c31d1c3735bcc1a000c8fa271ddb1d74bdbed5d8172773b23c205cfbe2bd2c8d9441a1dddf15ed217b3db8bb319dbba98c0aba7168fb54f7d4ad48686756ae", ip: "::", listenAddr: "[::]:3344", name: "Geth/v1.6.7-stable-ab5646c5/linux-amd64/go1.8.1", ports: { discovery: 3344, listener: 3344 }, protocols: { eth: { difficulty: 5019712, genesis: "0x29a42341a89cace1a303a40ca106b875f0ea4113a6e0a39dbbc663e9dfb8fb3f", head: "0x5b55cf4218401f08846d4c416ae947d2db2314722641fec49889917de22583c1", network: 12345 } }}
制作镜像
root@3ac09729dadb:/privategeth# ucsmy@QKTEST21191:~$ ucsmy@QKTEST21191:~$ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES3ac09729dadb daocloud.io/ubuntu "/bin/bash" 23 minutes ago Up 23 minutes 80/tcp node
commit制作镜像
ucsmy@QKTEST21191:~$ docker commit node daocloud.io/ubuntu/nodesha256:9ad689891d6dea2111a95200d7118da9e7d835b4ec5ed268a3eeb55ce8428077查看镜像ucsmy@QKTEST21191:~$ docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEdaocloud.io/ubuntu/node latest 9ad689891d6d 7 seconds ago 3.72 GB
用我们自己的镜像创建一个容器代表新节点
ucsmy@QKTEST21191:~$ docker run -it --name node1 daocloud.io/ubuntu/noderoot@976cd835a4d4:/# geth --datadir ./data --networkid 12345 --rpc console 2>>geth.logWelcome to the Geth JavaScript console!instance: Geth/v1.6.7-stable-ab5646c5/linux-amd64/go1.8.1 modules: admin:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0
先退出来,我们用shell脚本练练手
vi start.shgeth --datadir ./data --networkid 12345 --rpc console 2>>geth.logroot@976cd835a4d4:/# /bin/sh start.sh Welcome to the Geth JavaScript console!instance: Geth/v1.6.7-stable-ab5646c5/linux-amd64/go1.8.1 modules: admin:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0
注意:
运行 Shell 脚本有两种方法:
1、作为可执行程序
将上面的代码保存为 test.sh,并 cd 到相应目录:
chmod +x ./test.sh #使脚本具有执行权限
./test.sh #执行脚本
注意,一定要写成 ./test.sh,而不是 test.sh,运行其它二进制的程序也一样,直接写 test.sh,linux 系统会去 PATH 里寻找有没有叫 test.sh 的,而只有 /bin, /sbin, /usr/bin,/usr/sbin 等在 PATH 里,你的当前目录通常不在 PATH 里,所以写成 test.sh 是会找不到命令的,要用 ./test.sh 告诉系统说,就在当前目录找。
2、作为解释器参数
这种运行方式是,直接运行解释器,其参数就是 shell 脚本的文件名,如:
/bin/sh test.sh
/bin/php test.php
这种方式运行的脚本,不需要在第一行指定解释器信息,写了也没用。
ucsmy@QKTEST21191:~$ docker run -it --name node1 daocloud.io/ubuntu/noderoot@1c31a8a50563:/# cd privategeth/root@1c31a8a50563:/privategeth# geth --identity "haha" --datadir ./data/00 --networkid 12345 --rpcapi "db,eth,net,web3" --port 2220 --rpcport 3330 consoleWelcome to the Geth JavaScript console!instance: Geth/haha/v1.6.7-stable-ab5646c5/linux-amd64/go1.8.1coinbase: 0xbbe5e5a1e36f018975e99ba3044d448253755a4cat block: 38 (Mon, 07 Aug 2017 09:25:20 UTC) datadir: /privategeth/data modules: admin:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0miner.start()nullminer.stop()trueeth.blockNumber46>
node2,node3的创建
docker run -it --name node3 daocloud.io/ubuntu/noderoot@185f7891c3c0:/# vi start.shcd privategethgeth --datadir ./data/00 init genesis.jsongeth --identity "haha" --datadir ./data/00 --networkid 12345 --rpcapi "db,eth,net,web3" --port 2220 --rpcport 3330 consoleroot@185f7891c3c0:/# /bin/sh start.sh admin.addPeer( "enode://5d1f52b69d7473389e77475a1e972f45215b184ad6734e9b77088f00cc311fe493ed8352359685dee79c64db50041351da60785801328cb5ada82ab206287d1c@172.18.0.2:2220")然后自动更新~ ~
第四个节点
ucsmy@QKTEST21191:~$ docker run -it --name node4 daocloud.io/ubuntu/noderoot@49970be515bb:/# vi start.shcd privategethgeth --datadir ./data/00 init genesis.jsongeth --identity "haha" --datadir ./data/00 --networkid 12345 --rpcapi "db,eth,net,web3" --port 2220 --rpcport 3330 --bootnodes "enode://5d1f52b69d7473389e77475a1e972f45215b184ad6734e9b77088f00cc311fe493ed8352359685dee79c64db50041351da60785801328cb5ada82ab206287d1c@172.18.0.2:2220" consoleroot@49970be515bb:/# /bin/sh start.sh
第五个节点连接第二个节点
docker run -it --name node5 daocloud.io/ubuntu/noderoot@49970be515bb:/# vi start.shcd privategethgeth --datadir ./data/00 init genesis.jsongeth --identity "haha" --datadir ./data/00 --networkid 12345 --rpcapi "db,eth,net,web3" --port 2220 --rpcport 3330 --bootnodes "enode://5d1f52b69d7473389e77475a1e972f45215b184ad6734e9b77088f00cc311fe493ed8352359685dee79c64db50041351da60785801328cb5ada82ab206287d1c@172.18.0.2:2220" consoleroot@49970be515bb:/# /bin/sh start.sh
测试都可以完成,接下来把这个单节点镜像上传到阿里云
首先要在阿里云创建名称空间,创建镜像仓库
然后将镜像推送到registry:
ucsmy@QKTEST21191:~$ docker login --username=15622149705 registry.cn-hangzhou.aliyuncs.comPassword: Login Succeededucsmy@QKTEST21191:~$ docker tag 9ad689891d6d registry.cn-hangzhou.aliyuncs.com/ethblock/ethereum:latestucsmy@QKTEST21191:~$ docker push registry.cn-hangzhou.aliyuncs.com/ethblock/ethereum:latestThe push refers to a repository [registry.cn-hangzhou.aliyuncs.com/ethblock/ethereum]7d1a213def16: Pushed 54242b7256cd: Pushing [============================> ] 2.064 GB/3.595 GB33f1a94ed7fc: Pushed b27287a6dbce: Pushed 47c2386f248c: Pushed 2be95f0d8a0c: Pushed 2df9b8def18a: Pushed ^C
阅读全文
0 0
- 制作镜像并上传到阿里云
- Docker镜像上传到阿里云
- Docker镜像上传到阿里云
- Android头像的选择并上传到阿里云服务器
- linux docker安装 制作Elasticsearch容器镜像 并上传docker hub
- 上传图片到阿里云
- 阿里云maven镜像
- 阿里云maven 镜像
- 阿里云maven镜像
- 上传图片到阿里云并生成url的工具类
- Ubuntu Linux定时备份数据库,并上传到阿里云OSS
- docker创建镜像并上传dockerhub
- 安卓上传图片到阿里云
- SCp上传文件到阿里云服务器
- Wordpress上传到阿里云服务器
- java上传图片到阿里云
- 上传视频到阿里云服务器
- java 上传文件到oss(阿里云)
- linux实验楼学习笔记3
- No typehandler found for property XXX
- 苹果手机数据丢失找回方法及其数据备份汇总
- javascript第一天:变量和引入了bootstrap、javascript的html
- Hbase容器化
- 制作镜像并上传到阿里云
- 线程状态和安全
- 基于JPCAP的局域网嗅探器1.0
- 算法训练 明明的随机数
- 《面试》求2个数的最大公约数和最小公倍数
- SpringMVC_RequestContextHolder获取请求参数
- C# MEF
- Linux学习总结(39)——系统管理员应该知道的 20 条 Linux 命令
- quartz 定时任务