How to use Docker and migrate your existing Apps to your Linux Server?

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
are you still running your applications your website's databases or your linux servers without docker so maybe you've heard about it before but you don't really know why you should use it or how to get start with that so don't worry it's not that hard so in this video we will cover all the basics about containerization and docker on linux servers and how you can easily migrate all your existing applications such as websites and databases into darker containers everybody how you doing my name is christian and i'm creating tutorials and content for it professionals so if you want to learn more about containerization docker linux servers devops processes and all this stuff please don't forget to hit the like button and of course subscribe to the channel and in this video i will explain to you why docker is such an amazing and important tool for any it company nowadays and why every it professional now should take a look at this and of course i will also talk about some of the fundamentals and how you can use it to migrate your existing applications such as websites or databases into containers and thanks to portena who is the sponsor of this video we will also take a look at how you can easily manage all your docker resources on your linux server in a nice graphical web interface you also don't need to write down any commands or take notes somewhere just have a look at the video description below it will take you to my written blog article there you can read the full write up and just copy and paste all the links in the commands okay so enough for the introduction let's just start and talk about what docker actually is so first of all docker is a free and open source tool to containerize applications and containerization means we can run applications isolated from each other and deploy them in packages and this has some big advantages over the traditional deployment or installation process of applications on our servers because we can just download the image and run the container without carrying what is installed on our server underneath we can always be sure that the application will run as intended so no matter which linux distribution we are using or which software and packages we've installed in which version on our server and some people may now say well this sounds pretty similar to virtualization because it also provides us in a layer of abstraction between the host and our applications and yeah you may be right so virtualization is often compared to containers but it is not really the same containers only run on the same type of operating system that is installed on the host so you can only run windows containers on a windows host and linux containers on a linux host and this is because the container images don't include a full operating system stack in fact they only include the containerized application and all the necessary libraries and packages the developers have packaged inside the image but this allows us to do some very cool things because these docker images are usually very lightweight and so much more resource efficient than a virtual machine and they start up just incredibly fast so container image will just boot up in one or two seconds and they are very scalable therefore containers are often used in modern it business for example cloud infrastructure where scalability and high availability is a very big topic so because of all these advantages containerization has become a very common and essential standard in modern it business and you can imagine it is nowadays very important to learn this stuff so no matter if you are a software developer who is developing applications nowadays in containers or if you are a sys admin who is managing infrastructure or a cloud engineer so nowadays you will always get in touch with containerization somewhere in your it career and therefore this is a topic i also often cover on this channel because i believe this is already a very essential and fundamental skill in modern it business so i hope you are now excited about docker just as i am and you just want to get started with that and just take a look how it works and how you can easily use that on your own servers and migrate your application inside these resource efficient containers so first of all let's download docker and install that on your local workstation if you want to try it out on your windows machine for example as i said linux containers cannot natively run on a windows operating system but don't worry there's an easy solution to that because microsoft has just recently released the windows subsystem for linux which is a small virtual machine that can run a full linux operating system inside windows 10. and to know how to do that you can simply just go to the docker home page and install the windows subsystem for linux with a docker desktop back-end so just read this article and follow all the instructions it's not very difficult so just install windows 10 in a specific version then just enable the wsl2 feature for detailed instructions just follow this link to the microsoft documentation and then just download and install the linux kernel update package and then you can run an ubuntu distribution or another distribution inside your windows 10 machine with windows subsystem for linux which is really awesome i've already prepared this and if you want to know how to set up your windows terminal awesome like this here with zsh and some custom fonts and icons then just check the link in the video description i've put you a link to my tutorial where i'll show you how to set up this it's really awesome so try it out and to install docker you can just go to the official home page and just search for this article here install the docker engine so you can see it is supported on many different platforms it also shows you how to install that on a macintosh or on a windows system with docker desktop and for any servers like centos debian ubuntu or whatever you can just click on this and follow the instructions it's not very difficult you basically can just follow everything in this article here you need to add the official repository of docker first to your server add the official docker gpg key then install the docker engine and then you should be fine and if you have installed docker you should always make sure that your user has the correct permissions to execute any darker commands and you can easily just add your current user to the docker group to give the user the right permission so just type in sudo user mod dash a g for add group then the docker group and your username in my case exit and you usually need to lock out and log into the shell again and then you should be able to execute the docker command for example let's just execute docker double dash version to check the current version and if you see a screen like this it should all work and we can now just start deploying offers docker containers and as i said in the beginning we don't need to install any applications anymore we can just download a docker image with our desired application and just run it a docker has also simplified the whole process for us because we can just run a container and if we don't have download the image docker will automatically search for that image on the docker hub and download it for us so for example if you want to run a simple application to just test and try it out just execute docker run hello dash world so this will automatically download and run the test container you can see hello from docker if you see a message like this everything works correctly and it should also immediately exit our test container so can you see how simple this is it is not really difficult and this is basically the way how you can get all your applications you want to deploy inside containers if you want to find some useful applications for example a web server with nginx you can of course also do that so i would recommend you to go to the docker hub because the docker hub is just like a public repository where you can push and download docker images so for example let's just search for nginx which is a web server and you can see there is the official angelix web server docker image it is updated 15 hours ago so when you click on that you will usually find some detailed instructions how to use that docker image and some commands how to set up stuff but don't worry about these complicated commands i will show you that step by step so first of all let's just run a simple web server so to do that just type in docker run and then we also need to expose the port 80. because as i said these containers are isolated from each other and docker also isolates the network stack so if you want to get access to any container you always need to expose the correct network ports so in our example a simple web server without https will just use the port 80 so we will expose the port 80 and we will run it in the background with a d parameter and then we want to run the nginx docker image because i've previously downloaded and tested this image it won't download it again so it will just run our container and to check if our container or our application is running we can always execute the docker ps command so this will show us all containers that are currently running on our system you can see it automatically runs the nginx docker image it also created a random generated name which usually sounds pretty weird and it also exposed this application on port 80. so that means we can now open a web browser and just go to our localhost on port 80 and you can see this is welcome page of nginx we've just deployed our web server with docker this is pretty easy right so well one problem we have with containers is that dotcom containers are immutable and that means every changes we are making inside these darker containers once we are stopping the containers or it crashes and we start it again all these changes are gone but don't worry there's a very simple solution to store data persistently inside docker containers and this is called docker volumes with docker volumes we can mount a specific data location or mount point inside our container and you always should refer to the documentation of the docker images which data should be stored persistently and every time you change a configuration of a container you always need to stop and redeploy the containers these containers are not made to run forever they are immutable and they are meant to be deployed and redeployed pretty quickly so we can just stop the container with the docker stop command and we now can just use the name of our container or we can use the container identifier which is always unique on our system and to remove our container we can just execute docker roof in the same identifier so now we can just redeploy our nginx web server with a persistent storage location of our websites right so we can just type in docker run but now we want to add a volume that is called nginx data and now we can just add this location or we can refer to the official documentation and just use this location we always want to run this in the background and of course we also should use the nginx image so let's execute this again and it automatically should run a new docker container so with docker ps we can see there is a new container that has become a new name and it is now online again so if we just go and reload the web page you won't see a difference but once we step into the container or won't make any changes to the website all these changes are no persistently stored and we can also remove the container and redeploy it again because you can see even if we remove the container our volume is still there on the operating system for example if we execute docker volume ls we can see our nginx data is still stored on our host operating system and if we mount the same docker volume inside a new container our data is still there okay great so we can use docker volumes to store data persistently on the host operating system and we can just use that to deploy any web servers or database servers where our data is stored but how to migrate data inside these docker volumes because you cannot just access them somehow on the host operating system for example if we execute the docker inspect nginx data we can see that the data is actually stored in this location but once you try to access it you can see you cannot really access it from the host os and therefore we have a different method to migrate data inside darker containers and this is also pretty easy so for example if you have installed an nginx web server on your host operating system you should first stop the nginx web server and disable it and then you can just simply run an nginx container image and just mount the same location where your website is stored inside the container for example you can do this with a docker run but instead of our name docker volume we will now use the location user share nginx html and because i've not used this location on the host operating system it probably won't work but what you can now do is you can copy your existing website of your web server from any location where you have stored and copy this inside this user share and next location on the host operating system and it will automatically be mounted inside the container so for example if you go to this location and just add a simple website for example let's add an index html and let's create a very simple website for example let's just create a website that says hello doctor and just save and exit this and now we reload our page you can see that our website is now served and this is because we have mounted the same location on the host system inside our docker container and this is an easy way how you can actually migrate any existing applications inside docker containers you need to find out where is the data stored for this application and then mount it inside the same location of your container or you can store that somewhere differently in your project folder and mount this into the location where the application expects the data okay guys but i've also promised you to show you a web interface where you can also manage all your docker resources in a nice graphical way because usually it is important to know the fundamentals and manage linux servers and containers via the cli but sometimes it's easier to use a graphical web interface it is more intuitive and you can also learn something by just exploring which different settings are possible in the web interface so we will use the portainer software which is an open source tool to manage darker servers and also larger cloud environments so if you want to learn more about portender just go to the official homepage portainer.io and they are introducing portena as a management application it works with kubernetes with docker docker swarm and also the azure aci and i mean both data centers and at edge devices so you can also connect remote servers i've also done other tutorials on portain if you want to try it out and look at it i've put you some of the tutorials in the description down below so check it out if you want to know how to deploy portena and expose that with a reverse proxy like the nginx proxy manager and secure the web interface with trusted ssl sorts but for this short demonstration we will just deploy port hana in the community edition which is completely for free and you can easily deploy on your linux server and i will show you how easy it is to manage darker containers with partina so you can read about this go to the official home page and read the instructions but let's also do this and deploy this software on our linux server and to do that we will of course use docker because docker is a way to go how we deploy our applications nowadays so let's do this so to run the portena web interface on our server we simply just execute docker run command and we want to run it in the background and then we also want to expose the port 8000 which is important if you're using the portena edge agent and want to manage remote servers with that you also want to use the port 9000 which is the default part of the web interface you could also set the container name to portainer and now you can also set the restart policy to always because by default your docker containers are not automatically started once your server is rebooted with setting the restart policy to always you will make sure that when your server is rebooting for any software updates all your containers that are set this policy will also come up online automatically we also need to pass a volume that is called the va rundocker.sock so don't worry about it it is the docker api port and portena need to have access to this api port to be able to manage containers that are running on our host and of course we also want to store the data of portena in a persistent volume so now we can just use a named volume or if you want to see what's inside the container you can also use a mount point or location onto your host operating system and the docker image is called portena slash portainer ce that stands for the free and open source community edition of portena so let's hit enter and you can see it's now up and running if we now go to the host we can see that if we go to localhost and enter the port 9000 we are now on our portena web interface and first of all we need to create new initial administrator credentials here so just set up a password that is probably a bit more secure than this one here and let's just create a new user so now we need to select how we want to use portena to manage which resources because you cannot just manage your local docker environment you can also manage remote environments or a full kubernetes cluster which i would probably also cover on this channel in the future so make sure you are subscribing okay so let's manage our local docker environment and now we need to just simply connect to it and now it's up and running we can now select our local server and we have immediately access to all resources of docker that are running on our system so we can manage all containers you can see i've deployed some test containers before you can still see our enginex container we have just recently deployed and you can also see we can manage all the images that my system has downloaded previously we can manage docker networks which we will probably cover in upcoming videos and also docker volumes where you can store your data persistently so one thing that is very very useful on portena is we cannot just add a new container we can also edit existing ones so if you remember in the cli we always needed to stop and remove old containers if we want to change anything of the configuration inside here but on portena we can just simply click on our web server so for example if we want to add the restart always policy we can now just click on duplicate and edit and just go to the restart policy and click always so now we can just simply deploy the container and portena will automatically replace the existing container and will redeploy it with a new configuration so this is pretty comfortable and very nice if you want to manage your own home environment but a potato has also a business edition where it adds some multiple features like role-based access and all this stuff so if you want to use that in your company environment you definitely should go to the official home page and read about the business edition of portina it's very very cool check it out okay guys so i hope you learned something new and you are now excited about docker and want to try it out and you know how you easily can migrate all your existing applications on your servers now into darker containers which are pretty awesome so if you enjoyed this video please don't forget to hit the like button and of course subscribe to the channel if you want to watch more content and tutorials for it professionals and if you have any questions at any time then just join our awesome discord community we have a very great and friendly and respectful discord community of many talented it professionals so just try it out you will find a link in the description below so thanks everybody for watching enjoy the rest of your day take care of yourself and i hope i see you soon bye bye
Info
Channel: The Digital Life
Views: 4,942
Rating: 5 out of 5
Keywords: how to use docker, how to use docker containers, how to use docker desktop, how to use docker desktop in windows 10, how to use docker in linux, how to use docker in ubuntu, how to use docker in vscode, how to use docker on windows 10, how to use docker windows, docker, docker container, docker container basics, docker course, docker desktop, docker for beginners, docker hub, docker tutorial, docker tutorial for beginners, learn docker, what is docker container
Id: y0GGQ2F2tvs
Channel Id: undefined
Length: 19min 11sec (1151 seconds)
Published: Tue May 25 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.