byGink▻ Tue, 28 Nov 2023
dig
on AlpineWe can install dig
, nslookup
and their dependencies by adding package bind-tools
. These commands are very useful to check the IP address from the domain name.
apk update
apk add bind-tools
dig google.com
# ;; ANSWER SECTION:
# google.com. 39 IN A 74.125.200.101
# google.com. 39 IN A 74.125.200.102
telnet
on AlpineTelnet is a common way to verify the connection between your server to another one by testing connectivity to TCP ports.
Can install telnet
via this package busybox-extras
.
apk update
apk add busybox-extras
telnet google.com 80
# Connected to google.com
# Press [Ctrl + $] to quit
SSH is very useful when we need to allow different users access to the server via Linux account. Let's install OpenSSH
apk update
apk add openssh
# Generate host key if not existing
ssh-keygen -A
# Start SSH server
/usr/sbin/sshd -D -e "$@"
/etc/ssh/sshd_config
and modify these options:AllowTcpForwarding yes
TCPKeepAlive yes
PermitTTY yes
hey
or wrk
to benchmark HTTP servicesTools like hey
and wrk
are used for performance testing and benchmarking of web servers or web applications. They simulate a large number of concurrent users or requests to assess the system's capacity, performance, and response times under different loads.
apk update
apk add hey
apk add wrk
hey -z 30s http://localhost
wrk -d 30s http://localhost
curl
and jq
to access REST apisSometimes, we need to access internal REST api from the shell and check the response as Json. curl
and jq
are created for that.
apk update
apk add curl
apk add jq
How to use them?
curl
to access API in shell:curl http://localhost:8080/api
# {"status":"success"}
jq
for a better look:curl http://localhost:8080/api | jq
{
"status": "success"
}
jq
is pretty useful when you need to read a part of the json response. For example, the api at http://localhost:8080/auth
replies a json with this format:
{
"data": {
"access_token": "your-token-here"
}
}
And what you really care about is the token. You can read it directly like this:
curl http://localhost:8080/auth | jq -r '.data.access_token'
Tips: Sometimes you may need to skip SSL verification due to self-signed certificate with internal services. Let's try:
curl -k https://localdomain.com/api
Sometimes you will need to know which ports are opening inside a container, which is based on alpine
.
In this case, lsof
or netstat
can be useful.
No need to install as these tools should be available with alpine
already.
(sudo) lsof -i -P -n
# or
netstat -tulpn
speedtest-cli
for bandwidth checkingYou might need to check how fast is your network where your container is running. speedtest
will provide a quick look.
apk update
apk add speedtest-cli
How to use it?
speedtest
© 2016-2024 GinkCode.com