OSX terminal vs Docker CLI - macos

I'm not able to get what is the purpose of Docker CLI (started by Kinematic) - vs regular OSX terminal.
I have docker command available in both (OSX terminal and Docker-CLI), but when typing in:
//OSX terminal
$ docker images
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
// Kinematic terminal
$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
mariadb 5.5.47 a31b2e03c00b 6 months ago 238.8 MB
mysql latest d617bcfd159e 6 months ago 360.3 MB
mysql 5.7.9 a5ad9eb2ff48 8 months ago 359.9 MB
<none> <none> 9ee13ca3b908 8 months ago 125.1 MB
and the same for the rest of the commands like docker-compose up, they work at the terminal started with Kinematics but not on my local terminal.
Can you please explain me what I'm missing here?

This is due the virtualization of the Docker environment on MacOS. The docker environment is not available as a native application but contained in a virtual machine. See the docs:
Docker for Mac is our newest offering for the Mac. It runs as a native
Mac application and uses xhyve to virtualize the Docker Engine
environment and Linux kernel-specific features for the Docker daemon.
You do not need to access that machine manually in any way. The Docker Terminal listed under your Applications as well as Kitematic will do that for you.
However, if you take a look at the virtual machines listed in VirtualBox you will find a VM named default which is the one created during the Docker installation.
So the docker CLI is kind of a adapter between your local OSX terminal and the terminal of the Docker environment. The CLI somehow pipes the commands from your OSX terminal to the Docker environment.

Related

why docker container is not runnig in windows?

Help me friends, please. I'm a noob in docker.
I'm working with laravel an create project with Docker in location.
root#VIGIA-PC:/mnt/d/projects/fastfood-app/fastfood-api#
docker was working but when I shut down my pc, and then I turn on it, the docker container is not running, why?
when I go to to the project folder and type ls no appear files from debian terminal, when I going to windows they are here.
I runned docker ps and show the follow:
Information
windows version 10
distro linux debian
build 19042
Docker version 20.10.2, build 2291f61
You'll have to change the behavior of your docker apps.
If the host is being restarted, so are the containers running on it : https://docs.docker.com/config/containers/start-containers-automatically/
I have already solved my problem.that was a problem from path

Connecting Docker Windows WSL Ubuntu to VMware Ubuntu

I am trying to connect my Windows 10 Home system to be able to run full Linux OS Docker containers. I have installed Docker on both WSL Ubuntu 18.04 as well as a VMware Ubuntu 18.04.
I was trying to follow this guide.
However, I get stuck trying to configure the Daemon as per the instructions.
Can’t use Docker for Windows?
This is only necessary if you are NOT running Docker for Windows!
No problem, just configure your Docker daemon to use -H tcp://0.0.0.0:2375 and --tlsverify=false. Then you can follow along with the rest of this guide exactly.
If you go down this route, I highly recommend rolling your own VM with VMware Player instead of using the Docker Toolbox because VirtualBox has crazy edge case shared folder bugs that will ruin your life at some point. Don’t worry, VMware Player is free. Just Google how to set up Ubuntu 16 server on VMware Player.
When I try to change the Docker Daemon by making a daemon.json file I get errors. I've also tried editing the .profile files and the .bashrc as per other guides (another guide), with no luck.
I am unable to check the DOCKER_HOST variable on the VM Ubuntu.
Don't make things complicated. In your case, why WSL if you just want to connect to a remote daemon? Why not simply use the windows docker client?
Setup you favorite local VM with docker.
Example: I have installed a CentOS distro running on local VMWare Workstation. All Hyper-V of course deinstalled/deactivated.
In this VM, enable tcp access for the daemon.
If you have a systemd linux distro (like mine CentOS), execute this:
sudo mkdir -p /etc/systemd/system/docker.service.d
sudo echo '[Service]
ExecStart=
ExecStart=/usr/bin/dockerd -H unix:// -H tcp://0.0.0.0:2375' >> /etc/systemd/system/docker.service.d/options.conf
sudo systemctl daemon-reload
sudo systemctl restart docker`
Test if the port is open with docker info. You should get an API access warning at the bottom result.
Download the Windows docker cli zip from here: https://download.docker.com/win/static/stable/x86_64/
Move the docker.exe to any folder, for ex. your Documents folder.
Then put this folder path into your Windows PATH variable.
Set the docker host: Open PowerShell, execute setx DOCKER_HOST <VM-IP>:2375 and close it.
Open a new PowerShell and call docker info.
You should see the docker and daemon infos.
Do what ever you like now... :-)

the command "docker-machine ls " list nothing on my mac

I installed the latest stable docker for Mac, and started the docker directly without a virtual box. I know that it must have started a virtual box, so I use "docker-machine ls" to find the default machine, but it list nothing. How can i find the virtual machine? My OS version is 10.10.5
PS:
In fact, I didn't create any virtual machines, but do run my spring-boot app on the "alpine-oraclejdk8" image, so does that mean I exactly using the docker? And the reason I want to find the virtual machine is I used "nsenter" to enter the container to debug the log of my app but it doesn't work(the writer of "nsenter" told that I need enter the virtual machine first). So this is my confusing point that how the docker is running but I cant find the virtual machine on MAC
Docker for mac does not use docker-machine. The app that runs and give you the little whale icon in the top menu bar runs its own virtual machine. This virtual machine uses hyperkit, which is a project that uses xhyve, which is a port of bhyve to the mac os darwin kernel.
This will not create any entries to make docker-machine aware of the vm.
Rather than using nsenter to enter your container, you should use the docker exec command instead. The advantage of using docker exec is that it works without having the first ssh to where docker is running.
Because you need to create it.
Run the command
docker-machine create vm1
And you'll have your machine.
To redirect your docker client to the specific machine use this command
eval $(docker-machine env vm1)
Where 'vm1' is the same 'vm1' name that you used to create the machine. You can have a number of docker machine running at the same time using various backends like virtualbox or aws

Docker can not run on Windows 10 linux child system

I just install the Windows 10 Anniversary update which has a new feature that linux child system. So I try to run docker in Windows 10 ubuntu bash(linux child system). Why I want to install docker in linux child system is because:
Windows 10 native docker 1.12 need Hyper-V, but Vmware couldn't run if Hyper-V enable. I have a lot images created by Vmware, it isn't so easy to switch to Hyper-v
I don't want to use Docker Toolbox, it need install VirtualBox, just redunant.
apt-get is fine, docker install success, but fail to start.
$ sudo service docker start
initctl: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused
* Starting Docker: docker [ OK ]
$ docker ps
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
I have seen this post can-you-run-docker-natively-on-the-new-windows-10-ubuntu-bash-userspace, some people says that it is no posible to run docker in such linux child system, but there also some contrary opinions.
So, I want to ask is there any way to walk around this? Or I have to wait MS update this child system(since it is still beta now).
You have two Problems in there:
the linux child system does not provide the upstart service like e.g. ubuntu. You can work around this by running the docker deamon directly in foreground with docker daemon ...
This does nearly shure not work because docker requires features of the linux kernel like namespaces and capabilities. I don't think the NT-Kernel does implement such exotic features.

How will a Docker application with ubuntu as base image work on Windows?

I am new to docker and trying to understand the concept of base image.
Let's say I have a hello-world docker app on windows machine with ubuntu as base image in Dockerfile.
Now to run this hello-world application, Is docker going to install the whole ubuntu to run the application?
If not then how ubuntu base image will be used here and How will Docker container facilitate the commutation between ubuntu based application and windows OS?
Now to run this hello-world application, Is docker going to install the whole ubuntu to run the application?
No, the ubuntu image used is not "the whole ubuntu". It is a trimed-down version, without the all X11 graphic layer. Still 180 MB though: see "Docker Base Image OS Size Comparison".
These days, you would rather use an Alpine image (5 MB): see "Docker Official Images are Moving to Alpine Linux"
Regarding the hello-world application specifically, there is no Ubuntu or Alpine involved. Just 1.8 KB of C machine-code, which makes only direct calls to the Linux kernel of the host.
That Linux host is used by docker container through system calls: see "What is meant by shared kernel in Docker?"
On Windows, said Linux host was provided by VirtualBox VM running a boot2docker VM, built from a TinyCore distro.
With the more recent "Docker for Windows", that same VM is run through the Hyper-V Windows feature.

Resources