This tutorial explains how to install Docker on Ubuntu 21.04, highlighting Docker as an efficient open platform for building, testing, and deploying applications. Docker simplifies and accelerates the deployment process, making it less time-consuming to build and test applications. The guide is ideal for anyone looking to streamline their development workflow using Docker on the Ubuntu system.
How to install Docker on Ubuntu
To install Docker on Ubuntu, you can follow these steps:
How to install Docker on Ubuntu 21.04. After completing these steps, Docker should be successfully installed on your Ubuntu system, and you can start using Docker commands to manage containers and images. I hope will this your helpful. Thank you for reading the DevopsRoles page!
In this tutorial, how to use the fd command in Linux. fd command-line tool to find files in the file system. this tool is very simple.
The “fd” command is not a standard command in Linux. It seems that you might be referring to a specific command that is not part of the core Linux utilities.
What is the ‘fd’ Command?
The ‘fd’ command is a powerful and user-friendly tool that facilitates file searches within the Linux file system.
Although not a native Linux command, it is often considered a better and more intuitive alternative to the ‘find’ command. ‘fd’ is built on Rust, which contributes to its speed and efficiency.
Install fd command
Before you can start using ‘fd’, you need to install it on your Linux system. In this section, we’ll cover how to install ‘fd’ using popular package managers like ‘apt’ and ‘yum’, as well as from source.
(Optional) Create an alias for fd that refers to fdfind.
alias fd=fdfind
(Optional) To make the alias permanent.
vi ~/.bashrc
#Add this entry to the bashrc file
alias fd=fdfind
Use the fd command in Linux
Before using the fd command in Linux, we need to read the help of the command.
# fd --help
The output terminal as below
Find all files and directories starting with “abc” followed by any number of digits, you can use the following command:
fd -e "^abc\d+"
find all files that were changed before a specified number of days
$ fd index /home/vagrant --changed-before 365d
Finding Files Inside a Specific Directory
$ fd password /etc
Finding Files Based on Extension
$ fd -e html
Finding Hidden Files
$ fd -H bash
More details information about fd command.
man fd
Conclusion
fd command is a simple command in Linux. It uses the number of lines of files. These are just a few examples of how you can use the “fd” command.
For more advanced usage and options, you can refer to the documentation or help of the specific “fd” implementation you have installed on your system, as there are multiple versions available. Thank you for reading the DevopsRoles page!
In this tutorial, We will deploy a container Nginx server, modify it, and then create a new image from that running container. Now, let’s go to Create Docker Image from a Running Container.
What does docker mean?
Docker is a set of platform as a service products that use OS-level virtualization to deliver software in packages called containers. Containers are isolated from one another and bundle their own software, libraries, and configuration files Quota from Wikipedia
Install Docker on Ubuntu
If you don’t already have Docker installed, let’s do so. I will install Docker on Ubuntu Server. I use Ubuntu version 21.04 to install Docker.
To install Docker on Your Ubuntu server command below
sudo apt-get install docker.io -y
Add your user to the docker group with the command below
sudo usermod -aG docker $USER
Logging out and logging back in to ensure the changes take effect.
Create Docker Image from a Running Container
Create the New Container
We will create the new container with the command below:
vagrant@devopsroles:~$ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
fe3d2e383b80 nginx:alpine "/docker-entrypoint.…" 11 minutes ago Up 8 minutes 0.0.0.0:80->80/tcp, :::80->80/tcp nginx-devops
vagrant@devopsroles:~$ sudo docker stop fe3d2e383b80
fe3d2e383b80
vagrant@devopsroles:~$ sudo docker rm fe3d2e383b80
fe3d2e383b80
vagrant@devopsroles:~$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
vagrant@devopsroles:~$ sudo docker create --name nginx-new -p 80:80 nginx-devops-container:latest
91175e61375cf86fc935c55081be6f81354923564c9c0c0f4e5055ef0f590600
vagrant@devopsroles:~$ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
91175e61375c nginx-devops-container:latest "/docker-entrypoint.…" About a minute ago Created nginx-new
vagrant@devopsroles:~$ sudo docker start 91175e61375c
91175e61375c
vagrant@devopsroles:~$
What is the difference between docker commit and docker build?
docker commit creates an image from a container’s state, while docker build creating an image from a Dockerfile, allowing for a more controlled and reproducible build process.
Refresh your web browser and you should, once again, see the DevopsRoles page, New Stack! Welcome page.
YouTube: Create Docker Image from a Running Container
Conclusion
Create Docker Image from a Running Container is a powerful feature that enables you to capture the exact state of an application at any given moment. By following the steps outlined in this guide, you can easily commit a running container to a new image and use advanced techniques to add tags, commit messages, and author information. Whether you’re looking to back up your application, replicate environments, or share your work with others, this process provides a simple and effective solution. I hope will this your helpful. Thank you for reading the DevopsRoles page!
Welcome to this tutorial, where we’ll guide you through the process of install Nodejs on Rocky Linux or RHEL Linux using Vagrant. Node.js is a powerful runtime that allows you to run JavaScript on the server side, making it a crucial component for various web applications and development projects. With the help of Vagrant, we’ll simplify the installation process and ensure a smooth setup on your Rocky Linux or RHEL Linux environment.
What does Nodejs mean?
Node.js is an open-source, cross-platform, back-end JavaScript runtime environment that runs on the V8 engine and executes JavaScript code outside a web browser. quote from Wikipedia.
My Setup for Installing Node.js with Vagrant
Host OS: Window 11
Vagrant version: 2.2.18
Vagrant provider: VirtualBox
Boxes Vagrant: rockylinux/8
Terminal/PowerShell
The structure of the Vagrant directory and files will appear as follows:
I created aninit-nodejs.sh script to Install Node.JS from Nodesource Repositories or Install Node.JS from Rocky Linux AppStream Repositories.
The script content is as follows:
#!/bin/bash
# Update your system
sudo yum update -y
#Tools
sudo dnf install -y git unzip net-tools
# Install Node.JS from Rocky Linux AppStream Repositories
#sudo dnf module list nodejs -y
#sudo dnf module install nodejs:14
#sudo dnf install nodejs
#node -v
#npm -v
# Install Node.JS from Nodesource Repositories
# curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash - # For ubuntu Server
curl -sL https://rpm.nodesource.com/setup_16.x | sudo bash -
sudo dnf install nodejs -y
# Check version
node -v
npm -v
echo "##########################"
echo "Run npm install and then run app..."
echo "##########################"
#mkdir sample-app
#cd sample-app
#sudo npm install
#sudo forever start server.js
echo "##########################"
echo "Success! Navigate to localhost..."
echo "##########################"
Set Up a Virtual Machine
Navigate to my working directory
cd Rocky-Nodejs
vagrant init rockylinux/8
Configure the Virtual Machine
Edit the Vagrantfile and paste the content below
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "rockylinux/8"
config.ssh.insert_key = false
config.vbguest.auto_update = false
# Uncomment this if you want to link to a shared folder (e.g. if you are running source control and want to link it to Vagrant)
config.vm.synced_folder "./sample-app", "/home/vagrant/sample-app", create: true, group: "vagrant", owner: "vagrant"
config.vm.define "nodeserver" do |nodeserver|
nodeserver.vm.hostname = "devopsroles.com"
nodeserver.vm.network "private_network", ip: "192.168.4.4"
nodeserver.vm.network "forwarded_port", guest: 3000, host: 3000
nodeserver.vm.provision "shell",
path: "C:\\MyData\\Vagrant_VMS\\Projects\\Vagrant\\Rocky-Nodejs\\shell\\init-nodejs.sh"
end
end
Use Vagrant install Nodejs on Rocky Linux
vagrant up
To connect to Node Server.
vagrant ssh nodeserver
The output terminal is below
Check the Nodejs version that you have installed with the help of the following picture.
After you don’t use it, You delete Node Server.
Conclusion
To install Node.js on Rocky Linux, utilize Vagrant. I hope you find this information helpful. Thank you for visiting the DevopsRoles page!
In this tutorial, How to use Vagrant install Redis server. Vagrant, a powerful open-source tool, allows developers to create and manage lightweight, reproducible, and portable virtual machines effortlessly.
My Environment for Vagrant install Redis server
Host OS: Windows 11
Vagrant version: 2.2.18
Vagrant provider: VirtualBox
Boxes Vagrant: rockylinux/8
Terminal/PowerShell
Installed VirtualBox
The vagrant directory and files will look like as below:
I created an “init-redis.sh” script to install Redis Server on Rocky Linux. I use the provisioning shell of Vagrant to deploy Redis Server on Rocky Linux.
For example, the File “redis.conf” configures Redis Server as below:
bind 0.0.0.0
protected-mode yes
port 6379
tcp-backlog 511
timeout 0
tcp-keepalive 300
daemonize no
supervised no
pidfile /var/run/redis_6379.pid
loglevel notice
logfile /var/log/redis/redis.log
databases 16
always-show-logo yes
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
dir /var/lib/redis
replica-serve-stale-data yes
replica-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
replica-priority 100
lazyfree-lazy-eviction no
lazyfree-lazy-expire no
lazyfree-lazy-server-del no
replica-lazy-flush no
appendonly yes
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
aof-use-rdb-preamble yes
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-size -2
list-compress-depth 0
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
stream-node-max-bytes 4096
stream-node-max-entries 100
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit replica 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
dynamic-hz yes
aof-rewrite-incremental-fsync yes
rdb-save-incremental-fsync yes
requirepass devosroles.com
Create a Virtual Machine
I will navigate to my working directory. For example, the “Rocky-Redis” folder and create initialized Vagrantfile vagrant as the command below.
cd Rocky-Redis
vagrant init rockylinux/8
Configure the Virtual Machine
Edit the Vagrantfile and paste the content below
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "rockylinux/8"
config.ssh.insert_key = false
config.vbguest.auto_update = false
config.vm.define "redisserver" do |redisserver|
redisserver.vm.hostname = "devopsroles.com"
redisserver.vm.network "private_network", ip: "192.168.4.4"
redisserver.vm.network "forwarded_port", guest: 6379, host: 6379
redisserver.vm.provision "shell",
path: "C:\\MyData\\Vagrant_VMS\\Projects\\Vagrant\\Rocky-Redis\\shell\\init-redis.sh"
end
end
Deploy Redis Server on Rocky Linux
Use the command below to create and configures guest machines according to your Vagrantfile.
vagrant up
Finally, we will connect to the Redis server.
vagrant ssh redisserver
The output terminal as below
Conclusion
You’ve successfully installed the Redis server on a virtual machine using Vagrant. With this setup, you can now develop and test your Redis-dependent applications in an isolated and portable environment.
Vagrant’s ease of use and versatility make it an invaluable tool for any developer’s toolkit. I hope will this your helpful. Thank you for reading the DevopsRoles page!
In this tutorial, I wrote deploy Vagrant LEMP stack. I will install and configure the LEMP stack for this web application.
Vagrant is a powerful tool for managing virtual development environments, and the LEMP stack (Linux, Nginx, MySQL, PHP) is a popular choice for web developers due to its performance and flexibility. Combining Vagrant with a LEMP stack allows developers to create a consistent and reproducible environment, making development and collaboration more efficient.
What does lemp stand for?
Linux operating system, andNginx (pronounced engine-x, hence the E in the acronym) webserver. MySQL database and dynamic content processed by PHP.
My Environment for Vagrant LEMP stack
Host OS: Window 11
Vagrant version: 2.2.18
Vagrant provider: VirtualBox
Boxes Vagrant: rockylinux/8
Terminal/PowerShell
Vagrant directory and files will look like as below:
I created aweb-lemp-rocky.sh script to install Nginx, MySQL, and PHP on Rocky Linux. I use the provisioning shell of Vagrant to deploy LEMP on Rocky Linux.
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "rockylinux/8"
config.ssh.insert_key = false
config.vbguest.auto_update = false
config.vm.define "webserver" do |webserver|
webserver.vm.hostname = "devopsroles.com"
webserver.vm.network "private_network", ip: "192.168.4.4"
webserver.vm.network "forwarded_port", guest: 80, host: 8888
webserver.vm.provision "shell",
path: "C:\\MyData\\Vagrant_VMS\\Projects\\Vagrant\\Rocky-LEMP\\shell\\web-lemp-rocky.sh"
end
end
Deploy LEMP on Rocky Linux
vagrant up
To connect to Web Server.
vagrant ssh webserver
The output terminal is below
Opens a browser that can access your Server’s IP address.
Testing PHP
FAQs
What is Vagrant used for?
Vagrant is used for creating and managing virtual development environments, allowing developers to work in a consistent and isolated environment.
Why choose the LEMP stack over LAMP?
The LEMP stack uses Nginx instead of Apache, offering better performance and scalability for handling high-traffic websites.
How do I access the Vagrant VM’s web server?
You can access it using the IP address assigned to the VM or using a private network setup.
Can I use a different operating system for the Vagrant box?
Yes, Vagrant supports various operating systems, and you can specify a different box in the Vagrantfile.
Conclusion
Setting up a Vagrant LEMP stack is a powerful way to streamline your development process. By following this guide, you can create a consistent, isolated, and easily reproducible environment for your web development projects. Whether you’re a beginner or looking to implement advanced configurations, Vagrant provides the flexibility and control needed to optimize your workflow.
You have to use the Vagrant LEMP stack on Rocky Linux. I hope will this your helpful. Thank you for reading the DevopsRoles page!
In this tutorial, How to deploy multiple servers using Vagrant. I will deploy LAMP multiple servers. I create more VMs, each VM can have its own and different configuration.
My Environment
Host OS: Window 11
Vagrant version: 2.2.18
Vagrant provider: VirtualBox
Boxes Vagrant: rockylinux/8
Terminal/PowerShell
LAMP server architecture
Vagrant directory and files will look like as below: