— 1 min read
In the previous post, I talked about how to do the initial setup for Raspberry Pi. In this post, I will talk about the installation of the tools that are used most of the time in software development.
To put it briefly, Docker is a container technology that you can run an application in an isolated environment.
1-) Install Docker with snap
1sudo snap install docker
If it is ok when you execute the following command
1sudo docker run hello-world
You will see the following output
1Unable to find image 'hello-world:latest' locally2latest: Pulling from library/hello-world3256ab8fe8778: Pull complete4Digest: sha256:4cf9c47f86df71d48364001ede3a4fcd85ae80ce02ebad74156906caff5378bc5Status: Downloaded newer image for hello-world:latest67Hello from Docker!8This message shows that your installation appears to be working correctly.910To generate this message, Docker took the following steps:11 1. The Docker client contacted the Docker daemon.12 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.13 (arm64v8)14 3. The Docker daemon created a new container from that image which runs the15 executable that produces the output you are currently reading.16 4. The Docker daemon streamed that output to the Docker client, which sent it17 to your terminal.1819To try something more ambitious, you can run an Ubuntu container with:20 $ docker run -it ubuntu bash2122Share images, automate workflows, and more with a free Docker ID:23 https://hub.docker.com/2425For more examples and ideas, visit:26 https://docs.docker.com/get-started/
2-) Create a group named docker to be able to use docker commands without sudo
1sudo groupadd docker
3-) Add your user to the docker group
1sudo usermod -aG docker $USER
4-) Reboot your system
1sudo reboot
5-) If everything is ok you can able execute the following command without sudo
1docker run hello-world
1-) Pull and run the latest MongoDB from Docker with the name mongo
1docker run -d -p 27017:27017 -v ~/mongo/data:/data/db --name mongo mongo
With the -v parameter MongoDB data become persistent to Raspberry Pi's ~/mongo/data directory. In this way, we don't lose any data when we delete containers.
You can visually explore the database with MongoDB Compass also, you can use the following URL format to connect to DB via Compass
1mongodb://YOUR_RPIs_LOCAL_IP:27017
2-) You can access the mongo shell directly via the following command
1docker exec -it mongo mongo
1-) Install NVM (Node Version Manager)
1curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.36.0/install.sh | bash
It will generate the following output
1% Total % Received % Xferd Average Speed Time Time Time Current2 Dload Upload Total Spent Left Speed3100 13527 100 13527 0 0 2423 0 0:00:05 0:00:05 --:--:-- 29684=> Downloading nvm from git to '/home/ubuntu/.nvm'5=> Cloning into '/home/ubuntu/.nvm'...6remote: Enumerating objects: 316, done.7remote: Counting objects: 100% (316/316), done.8remote: Compressing objects: 100% (268/268), done.9remote: Total 316 (delta 36), reused 134 (delta 23), pack-reused 010Receiving objects: 100% (316/316), 169.68 KiB | 1016.00 KiB/s, done.11Resolving deltas: 100% (36/36), done.12=> Compressing and cleaning up git repository1314=> Appending nvm source string to /home/ubuntu/.bashrc15=> Appending bash_completion source string to /home/ubuntu/.bashrc16=> Close and reopen your terminal to start using nvm or run the following to use it now:1718export NVM_DIR="$HOME/.nvm"19[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm20[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
Execute the following commands as mentioned output or exit and reopen terminal to start using NVM
1export NVM_DIR="$HOME/.nvm"2[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm3[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
If everything is ok when you execute the following command
1command -v nvm
You will see the following output
1nvm
2-) Install latest NodeJS LTS version
1nvm install --lts
You will see an output like this
1Installing latest LTS version.2Downloading and installing node v12.18.4...3Downloading https://nodejs.org/dist/v12.18.4/node-v12.18.4-linux-arm64.tar.xz...4###################################################################################################################################################################### 100.0%5Computing checksum with sha256sum6Checksums matched!7Now using node v12.18.4 (npm v6.14.6)8Creating default alias: default -> lts/* (-> v12.18.4)