docker中什么是geth
在docker中,Geth是指由以太坊基金会提供的官方客户端软件,用Go编程语言编写的;Geth客户端提供了一个交互式命令控制台,该命令控制台中包含了以太坊的各种功能。
本教程操作环境:linux5.9.8系统、docker-1.13.1版、Dell G3电脑。
什么是geth
Geth是由以太坊基金会提供的官方客户端软件,用Go编程语言编写的。Geth提供了一个交互式命令控制台,该命令控制台中包含了以太坊的各种功能(API)。全名go-ethereum。
docker部署geth客户端
一 安装docker
自行百度
二 把上面这个镜像pull下来,pull最新的即可
docker pull ethereum/client-go
三 先说说docker run的参数
因为官方镜像如果直接启动会默认为geth,直接同步主网络,我们肯定是不希望他直接同步的,命令如下
docker run -d -it --name=node0 -u root -p 8545:8545 -p 30303:30303 -v E:\eth:/root --privileged=true --entrypoint /root/a.sh ethereum/client-go
-v 代表将本地文件挂载上去
--privileged 真正的sudo权限
--entrypoint 入口脚本,如果存在会覆盖掉dockerfile里的声明
我在这个脚本里选择了把私链初始化,如何初始化可以看官方教程和我之前的文章
我的脚本
#!/bin/sh #初始化创世区块 geth -datadir /root/data init /root/gener.json if [ $# -lt 1 ]; then exec "/bin/sh" else exec /bin/sh -c "$@" fi
四 启动私链
这里要注意一个问题,就是启动的参数又又又更新了
以前是--rpc --rpcapi,现在换成了--http balabala
HTTP based JSON-RPC API options:
--http
Enable the HTTP-RPC server--http.addr
HTTP-RPC server listening interface (default:localhost
)--http.port
HTTP-RPC server listening port (default:8545
)--http.api
API's offered over the HTTP-RPC interface (default:eth,net,web3
)--http.corsdomain
Comma separated list of domains from which to accept cross origin requests (browser enforced)--ws
Enable the WS-RPC server--ws.addr
WS-RPC server listening interface (default:localhost
)--ws.port
WS-RPC server listening port (default:8546
)--ws.api
API's offered over the WS-RPC interface (default:eth,net,web3
)--ws.origins
Origins from which to accept websockets requests--ipcdisable
Disable the IPC-RPC server--ipcapi
API's offered over the IPC-RPC interface (default:admin,debug,eth,miner,net,personal,shh,txpool,web3
)--ipcpath
Filename for IPC socket/pipe within the datadir (explicit paths escape it)
所以现在的启动命令就成了
geth --networkid 666 --http --http.addr=0.0.0.0 --http.port=8545 --http.api "web3,eth,debug,personal,net" --http.corsdomain "*" --allow-insecure-unlock --datadir /root/data console 2>>geth.log
接下来就该干什么干什么了
用web3连接测试一下
var Web3 = require('web3'); var Tx = require('ethereumjs-tx').Transaction; if (typeof web3 !== 'undefined') { web3 = new Web3(web3.currentProvider); console.log("1"+web3.version) } else { // set the provider you want from Web3.providers web3 = new Web3(new Web3.providers.HttpProvider('http://127.0.0.1:8545')); console.log(web3.version) }
推荐学习:《docker视频教程》
以上是docker中什么是geth的详细内容。更多信息请关注PHP中文网其他相关文章!

热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

记事本++7.3.1
好用且免费的代码编辑器

SublimeText3汉化版
中文版,非常好用

禅工作室 13.0.1
功能强大的PHP集成开发环境

Dreamweaver CS6
视觉化网页开发工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

热门话题

创建 Docker 镜像步骤:编写包含构建指令的 Dockerfile。在终端中构建镜像,使用 docker build 命令。标记镜像,使用 docker tag 命令分配名称和标签。

如何使用 Docker Desktop?Docker Desktop 是一款工具,用于在本地机器上运行 Docker 容器。其使用步骤包括:1. 安装 Docker Desktop;2. 启动 Docker Desktop;3. 创建 Docker 镜像(使用 Dockerfile);4. 构建 Docker 镜像(使用 docker build);5. 运行 Docker 容器(使用 docker run)。

要获取 Docker 版本,您可以执行以下步骤:运行 Docker 命令“docker --version”来查看客户端和服务器版本。对于 Mac 或 Windows,还可以通过 Docker Desktop GUI 的“版本”选项卡或“关于 Docker Desktop”菜单查看版本信息。

在 Docker 中保存镜像,可以使用 docker commit 命令创建新的镜像,包含指定容器的当前状态,语法为:docker commit [选项] 容器ID 镜像名称。要保存镜像到仓库,可以使用 docker push 命令,语法为:docker push 镜像名称[:标签]。要导入已保存的镜像,可以使用 docker pull 命令,语法为:docker pull 镜像名称[:标签]。

Docker 中将文件拷贝到外部主机的方法:使用 docker cp 命令:执行 docker cp [选项] <容器路径> <主机路径>。使用数据卷:在主机上创建目录,在创建容器时使用 -v 参数挂载该目录到容器内,实现文件双向同步。

可以通过以下步骤查询 Docker 容器名称:列出所有容器(docker ps)。筛选容器列表(使用 grep 命令)。获取容器名称(位于 "NAMES" 列中)。

Docker 进程查看方法:1. Docker CLI 命令:docker ps;2. Systemd CLI 命令:systemctl status docker;3. Docker Compose CLI 命令:docker-compose ps;4. Process Explorer(Windows);5. /proc 目录(Linux)。
