ALPINE COMMANDS
Posted: Mon Jul 24, 2023 2:14 pm
In previous topics i already discussed about Alpine Linux. Still a brief about alpine linux is smallest linux with full docker support.
Listing here few usefull commands for Alpine Linux.
1. Assign Static Ip Address:
2. If you have installed Alpine in virtual machine sometime harddisk size needs to be incresed. Accordingly partition table needs to be modified.
3. In virtuslbox disk size increases when application is installed or copied, but it remain extended evenif uninstalled/delete. To shrink the space one has to fill zero at free space. In Ubuntu a popular tool is used called zerofree. Though zerofree can be installed in Alpine, but as the disk is already mounted you cannot apply zero free. There is a way to zero fill free spaces in Alpine Linux.The code is:
After this we need to shrink the vbox hard disk from command prompt. Code is:
4. Sometime it is required to copy data from host machine to virtual machine running Alpine. A folder to be attached in virtualbox. Inside Alpine code is:
Then mount the above folder
vbox_shared is the 'Folder Name' you decided in the virtualbox gui
5. Sometime host machine dont have internet. To install docker one can pull in a machine with internet and export this image with docker save command. Then compress it and load it with host having no internet with docker load command. The code is:
In machine with internet:
In host machine without internet:
6. Sometime jupyter notebook is made to run inside docker with port: 8888 forwarded. Still when notebook is started it shows on localhost. In order to access it from outside, you need to bind it with 0.0.0.0. The code is:
7. Docker create interactive container with port forward:
8. Docker start:
9. Docker access bash:
10. See all open ports:
11. See a application loaction:
Listing here few usefull commands for Alpine Linux.
1. Assign Static Ip Address:
Code: Select all
auto eth0
iface eth0 inet static
address 192.168.0.25
subnet 255.255.255.0
gateway 192.168.0.1
Code: Select all
# after the virtual disk has already been expanded.
apk add --no-cache cfdisk e2fsprogs-extra
# choose partition then "Resize" > "Write" (to finalize)
cfdisk
# replace * with partition you are resizing
resize2fs /dev/*
Code: Select all
$ cat /dev/zero > zero.file
cat: write error: No space left on device
$ sync
$ rm zero.file
$ sync
Code: Select all
vboxmanage modifymedium --compact /path/to/thedisk.vdi
Code: Select all
mkdir -p /mnt/shared
apk add virtualbox-guest-additions linux-virt
reboot
Code: Select all
modprobe -a vboxsf
mount -t vboxsf vbox_shared /mnt/shared
5. Sometime host machine dont have internet. To install docker one can pull in a machine with internet and export this image with docker save command. Then compress it and load it with host having no internet with docker load command. The code is:
In machine with internet:
Code: Select all
apk add gzip
docker pull couchbase
docker save couchbase > couchbase.tar
ls -lh couchbase.tar
gzip -9 couchbase.tar
ls -lh couchbase.tar.gz
Code: Select all
docker load < couchbase.tar.gz
Code: Select all
jupyter-notebook --allow-root --ip 0.0.0.0 --port 8888
Code: Select all
docker create -t -i -p:3000:3000 --name myubuntu ubuntu:latest
Code: Select all
docker start myubuntu
Code: Select all
docker exec -it myubuntu /bin/bash
Code: Select all
netstat -lnptu
Code: Select all
which <application_name>