Docker is a container platform. Container is not a emulation of a service or a applications. it's like you put the application in the box and the application can't go out. If your application need dependencies or specific version. All that it need go in the box to. You can use this box on all system running your container software.
You go tell me : okay, great but docker is just for developper to run and develop apps. I will tell you : No, it's also for sys admin. you can use for testing all your config and service like : SQL, nginx, apache,etc.
You must install the package "docker" and "docker-compose".
You must install the .exe installer.
You must go on the website of docker and login.
You can also use Kubernetes for the orchestration of your docker machine but we will see that later.
To test if docker is correctly installed, you can use
Result returned by the above command must display something like that.
Docker version 17.12.0-ce
To get information about your installation you can use following command line.
She must display something like that.
Containers: 0 Running: 0 Paused: 0 Stopped: 0 Images: 1 Server Version: 18.06.1-ce Storage Driver: overlay2 Backing Filesystem: extfs Supports d_type: true Native Overlay Diff: true Logging Driver: json-file Cgroup Driver: cgroupfs Plugins: Volume: local Network: bridge host macvlan null overlay Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog Swarm: inactive Runtimes: runc Default Runtime: runc Init Binary: docker-init containerd version: (expected: 468a545b9edcd5932818eb9de8e72413e616e86e) runc version: N/A (expected: 69663f0bd4b60df09991c08812a60108003fa340) init version: v0.18.0 (expected: fec3683b971d9c3ef73f284f176672c44b448662) Security Options: apparmor seccomp Profile: default Kernel Version: 4.18.0-12-generic Operating System: Ubuntu 18.10 OSType: linux Architecture: x86_64 CPUs: 4 Total Memory: 5.718GiB
To test your docker use :
docker run hello-world
It's simple hello world application to test if your docker container works fine.
And a little cheatsheet for Docker command line :
## List Docker CLI commands docker docker container --help ## Display Docker version and info docker --version docker version docker info ## Execute Docker image docker run hello-world ## List Docker images docker image ls ## List Docker containers (running, all, all in quiet mode) docker container ls docker container ls --all docker container ls -aq
How to use docker every day
All of your services or applications can be run on Docker container.
To do that you must do only one thing, create a "Dockerfile".
Whitin this docker file you will describe your application and all the dependencies that you will need.
Here is an exemple:
# Use an official Python runtime as a parent image FROM python:2.7-slim # Set the working directory to /app WORKDIR /app # Copy the current directory contents into the container at /app COPY . /app # Install any needed packages specified in requirements.txt RUN pip install --trusted-host pypi.python.org -r requirements.txt # Make port 80 available to the world outside this container EXPOSE 80 # Define environment variable ENV NAME World # Run app.py when the container launches CMD ["python", "app.py"]
To build the app you must use Docker build.
docker build -t "your_image_name"
After that you can run your docker image.
docker run -p 4000:80 your_image_name