21
TheOct0
6y

I'm not knowledgeable when it's about Linux, so when I want to do some stuff I always have to take a f*cking lesson and a half. Could someone please explain to me what Docker is?

Comments
  • 2
  • 3
    Do yourself a big favor and learn it, it's worth the learning curve. You basically download disk images of various packages and run them in isolated containers.
  • 8
    For example, want to run a MySQL instance (and not have MySQL installed)? Just download the image for it and run it in a container via command line:

    docker pull mysql

    Then:

    docker run -p 27107:27107 mysql

    So, 27107:27107 is the external port (left of the : character), mapped to the internal port of the container (right of the : character).

    works on any OS (Linux/Windows/Mac).

    Just like that you have a MySQL instance up and running. When you're done, stop the container, remove it, and then remove the image.
  • 2
    Man I feel your pain.

    I just wanted to play music from an old CD to see what was on it. Took me 15 fucking minutes to figure out why it wasn't fucking reading and to install a new media center since th default one shit a brick.
  • 2
    There are thousands of different docker images you can download and run:

    https://hub.docker.com/explore/
  • 3
    Digital ocean has a good tutorial about it.

    P.S. it is second or third time I am mentioning digital ocean. I don't have any affiliation to it.
  • 1
    Advantage: instead of having to configure and do some complicated setup for somw fancy software, someone else can do that and upload it as a docker container, so you won't have to do it.
  • 4
    @TheOct0 Right so you know how a traditional virtual machine (KVM, VirtualBox, vmware etc) replicates a physical system down to hardware details (virtual CPUs and devices and all)? It basically tricks the guest operating system into thinking it's running on a physical machine, whereas it's actually just running inside a simulation of a machine (let's ignore paravirtualization here).

    VMs are absolutely great for isolation, you can run 10 OSes on one host and they'll behave as if you have 10 separate physical computers. The problem with that it's very resource intensive to do all that simulation. What if you just have ten applications that you need to run with reasonable isolation, and you don't actually need the "fake a machine" level of isolation?

    Enter Docker. It uses the host kernel to create operating system environments on top of the host kernel (an OS environment is basically everything that goes over the kernel - libraries, basic utilities, etc.)
  • 3
    @TheOct0 Think of a Docker container as a box running some application sitting on top of your kernel. The box contains everything the application needs to run, the only thing it goes to the host kernel for is system calls (disk I/O, etc.)

    So suppose you're on Arch and you installed Docker. You can then use Docker to run nginx or Apache web server in an Ubuntu container.

    Translation: you have a box containing the Ubuntu environment minus the kernel and with Nginx installed in it. Whenever you run this container, nginx will run inside this box using the provided Ubuntu environment instead of your Arch environment, but it uses your Arch kernel to do the work (this works great because the Linux kernel is common to all distros).

    Containers behave a lot like VMs in that you can "log in" to them (docker attach) and get a terminal running inside the container. Or you can just script an automated service inside it. Host a DB. Run build tools in isolation. Etc.

    Hope this made sense lol
  • 0
    Thanks a whole lot to all of you! That's a better start than I could have wished for. You all saved me an hour's worth of research with that :D
  • 1
    It's cool, but if you want it to be super secure, check out rkt.
  • 1
    @ewpratten Could I use a Docker image with that?
  • 1
    @TheOct0 rkt does have a way of running docker images. I don't remember how, but that's how I used to do docker stuff on my Chromebook.

    The internet should tell you.
  • 1
    @ewpratten Okay, thanks, I wouldn't have found that by myself :)
  • 1
    You can also link those containers internally. So, you can have an Apache container and an nginx container on you system. Also you have your php webapp. You start up you PHP container and your Apache container and link them. Your webapp now runs on an Apache/PHP stack. Now you can shutdown you Apache container and start you nginx container and link it with you PHP container. Now you have a nginx/PHP stack. All on one system within seconds. Same with different PHP versions. You can have a php5, php6 and php7 container. Just start them up and test on different PHP versions. "Docker compose" helps you with starting and linking those containers with just one file.
  • 1
    And if you are really crazy you can also use docker containers with PHPstorm for example. So u don't have to install anything on you PC but you can still use PHP, node, gulp, yarn, etc. within other programs.
  • 1
    Docker is like convienience food for server software. Just type in the command line "docker install [whatever]" and within a minute, this thing runs on your computer, without complicated configuration.
  • 0
    Docker is for pissing off Hitler, see this documentation:

    https://youtube.com/watch/...
Add Comment