Skip to content

Docker for algorand algod+node

Objective#

have a docker file and host the infrastructure of AlgoBuilder, which requirers algod and goal

Record#

Restart learning docker with video Docker Tutorial for Beginners [FULL COURSE in 3 Hours]. 43:28: binded -> bound.

  • Image := source code how to build the docker (dockerfile), all images on DockerHub are images.
  • Container := a copy/image of the "installed" app. with port bound and virtual file system.

Docker CLI#

docker run: build container from image; pull image if needed. flag -d: detached mod (not starting), -p: port, -i interactive, --name: name for container. docker start: start container. Normally, data will not persist between starts. Need use docker volumes for data persistence. docker exec: start a function (run a command) in container, will start if container is not stated. docker-compose -f: same as running it in command line with docker run but easier to reuse, with a docker network already set up. The network is created with up and will be removed when down. Dockerfile: a file that contains the instructions for building the image.RUN and CMD are both Linux command but CMD is the entry point of the image. Has to be named Dockerfile with capital D. docker build: build image from Dockerfile. docker rm: remove container. docker rmi: remove image. docker tag: rename image. docker login, docker push, docker pull: login, push, pull image from DockerHub or other private docker repository. docker volumes: Host volumes docker run -v /host/path:/container/path; Anonymous volumes docker run -v /host/path; Named volumes docker run -v $SOME_NAME:/host/path;

run amd64 docker image on M1#

[Docker platform on M1](./Docker platform on M1.md)

Plan#

  • Use Alpine. / ubuntu. check size. 3M vs 30M. Using Alpine. (supported by node)
  • Use go + Alpine (golang:alpine)
  • Alpine "cannot execute binary"
  • Testing ubuntu

code record#

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# init
# golang:alpine docker run -it --name abstr_algo_test golang:alpine /bin/sh
docker run -it --name abstr_algo_test --platform linux/amd64 -v root_persist:~/ ubuntuL:latest #/bin/sh
# alpine #apk add bash curl
# alpine #/bin/bash
apt-get update
apt-get install -y wget curl git

# algorand node
mkdir ~/node
cd ~/node
wget https://raw.githubusercontent.com/algorand/go-algorand-doc/master/downloads/installers/update.sh
chmod 544 update.sh # cannot use Alpine here
./update.sh -i -c stable -p ~/node -d ~/node/data -n

# golang
mkdir -p ~/tmp/go
cd ~/tmp/go
go_version='go1.18.linux-amd64.tar.gz' #1.18,amd64
go_url="https://go.dev/dl/$go_version"
curl -OL "$go_url"
rm -rf /usr/local/go && tar -C /usr/local -xzf "$go_version"
export PATH=$PATH:/usr/local/go/bin
go version
rm $go_version
cd ~
rmdir -p tmp/go

# go-algorand
git clone https://github.com/algorand/go-algorand
cd go-algorand
./scripts/configure_dev.sh ## have to use amd64
./scripts/buildtools/install_buildtools.sh ## have to use amd64
make install # takes a while ~15min on m1, with amd64 docker
cd ~

# AlgoBuilder infrastructure
git clone https://github.com/scale-it/algo-builder.git
cd algo-builder/infrastructure
make setup-private-net #may take a while

dockerfile#

1
2
3
4
5
6
FROM golang:alpine
RUN install basic, go-algorand, algo-builder.
RUN apk add --no-cache curl
RUN run-the-algorand-node-goal-thing
COPY files-from-host docker-image-path
CMD ["goal","run"]