Day 2 - 90daysofDevOps

Docker Beginners - part 2

Β·

2 min read

For installing docker in ubuntu machine and a few more basic commands are as bellow

sudo apt-get update                //updating latest packages in the server
sudo apt-get install docker.io     //installing docker 
sudo usermod -aG docker $USER      //adding docker user to the group file
cat /etc/group | grep -i docker    //checking if user is added or not
docker ps                          //to check if the docker container are working
docker run mysql:5.7               //creating docker container of mysql
docker exec -it <container_id> bash   //running the container in iteractive bash mode

Things to remember :

Docker File -> Docker Image -> Docker Container

Always, first the file is prepared (Dockerfile) , then using Dockerfile, image is created using Docker build command, and then Container is created from that image using Docker run command.

Dockerfile

Docker builds images by reading the instructions from a Dockerfile. A Dockerfile is a text file containing instructions for building your source code.

example of Dockerfile of a java application

 #Toget the base image from Dockerhub
FROM openjdk:11

#Create a wprking dorectory to compile java app
WORKDIR /app

#Copy code from local machine to the container(assuming we are in java app dir)
COPY Hello.java . 

#Compile the code
RUN javac Hello.java

#Run the java app
CMD["java","Hello"]

Charting Our Docker Adventure πŸ—ΊοΈ

Today's Docker tasks were like unlocking the hidden treasures of containerization. Sail through the sea of containers, and let's share our Docker stories on this #DevOpsJourney! βš“πŸŒ

Join me tomorrow for another thrilling DevOps challenge. Until then, keep Dockerizing! πŸ³πŸš€

Happy Containerizing! πŸŒŸπŸ‘¨β€πŸ’»

Β