- Docker MUST be running on Kernel version > 3.10 and using x86_64 kernel (CentOS 7, RHEL 7 ...etc)
- Create Docker Repo:
- Update your system:
- Install docker engine:
- Enable and start docker:
- List current docker version:
- List the current docker images (No images are added yet):
- It is not good idea to deal with docker as "root" user, as usually developers and so many people will use docker. The best action to have required people to deal with docker using their accounts:
1. Try to list docker images using "user" account, you will see the following error message:
2. Checking the docker socket file shows that it is owned by "docker" group which has now users:
3. Add "user" username to "docker group and then try again ( You will see the same error message again):
4. You need to logout "user" username and login again, then you will be able to list docker images:
[root@docker ~]# uname -a Linux docker 3.10.0-327.28.3.el7.x86_64 #1 SMP Fri Aug 12 13:21:05 EDT 2016 x86_64 x86_64 x86_64 GNU/Linux
[root@docker ~]# cat /etc/redhat-release Red Hat Enterprise Linux Server release 7.2 (Maipo)
- Create Docker Repo:
[root@docker ~]# vim /etc/yum.repos.d/docker.repo
[root@docker ~]# cat /etc/yum.repos.d/docker.repo [dockerrepo] name=Docker Repository baseurl=https://yum.dockerproject.org/repo/main/centos/7/ enabled=1 gpgcheck=1 gpgkey=https://yum.dockerproject.org/gpg
[root@docker ~]# yum repolist Loaded plugins: amazon-id, rhui-lb, search-disabled-repos dockerrepo | 2.9 kB 00:00:00 dockerrepo/primary_db | 25 kB 00:00:00 repo id repo name status dockerrepo Docker Repository 45+30 epel/x86_64 Extra Packages for Enterprise Linux 7 - x86_64 10,955 nux-dextop/x86_64 Nux.Ro RPMs for general desktop use 2,518 rhui-REGION-client-config-server-7/x86_64 Red Hat Update Infrastructure 2.0 Client Configuration Server 7 6 rhui-REGION-rhel-server-releases/7Server/x86_64 Red Hat Enterprise Linux Server 7 (RPMs) 13,288+290 rhui-REGION-rhel-server-rh-common/7Server/x86_64 Red Hat Enterprise Linux Server 7 RH Common (RPMs) 209 repolist: 27,021
- Update your system:
[root@docker ~]# yum update Loaded plugins: amazon-id, rhui-lb, search-disabled-repos No packages marked for update
- Install docker engine:
[root@docker ~]# yum install -y docker-engine
- Enable and start docker:
[root@docker ~]# systemctl enable docker Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
[root@docker ~]# systemctl start docker
[root@docker ~]# systemctl is-enabled docker enabled
[root@docker ~]# systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
Active: active (running) since Mon 2016-12-26 18:05:53 EST; 18s ago
Docs: https://docs.docker.com
Main PID: 1946 (dockerd)
Memory: 18.2M
CGroup: /system.slice/docker.service
├─1946 /usr/bin/dockerd
└─1949 docker-containerd -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --shim docker-containerd-shim --metrics-interval...
Dec 26 18:05:52 docker dockerd[1946]: time="2016-12-26T18:05:52.769046413-05:00" level=warning msg="mountpoint for pids not found"
Dec 26 18:05:52 docker dockerd[1946]: time="2016-12-26T18:05:52.769251739-05:00" level=info msg="Loading containers: start."
Dec 26 18:05:52 docker dockerd[1946]: time="2016-12-26T18:05:52.979766623-05:00" level=warning msg="Running modprobe bridge br_netfilter failed wit...
Dec 26 18:05:53 docker dockerd[1946]: time="2016-12-26T18:05:53.186341132-05:00" level=info msg="Firewalld running: false"
Dec 26 18:05:53 docker dockerd[1946]: time="2016-12-26T18:05:53.605435189-05:00" level=info msg="Default bridge (docker0) is assigned with... address"
Dec 26 18:05:53 docker dockerd[1946]: time="2016-12-26T18:05:53.699276984-05:00" level=info msg="Loading containers: done."
Dec 26 18:05:53 docker dockerd[1946]: time="2016-12-26T18:05:53.699483956-05:00" level=info msg="Daemon has completed initialization"
Dec 26 18:05:53 docker dockerd[1946]: time="2016-12-26T18:05:53.699504564-05:00" level=info msg="Docker daemon" commit=7392c3b graphdriver...on=1.12.5
Dec 26 18:05:53 docker dockerd[1946]: time="2016-12-26T18:05:53.706458243-05:00" level=info msg="API listen on /var/run/docker.sock"
Dec 26 18:05:53 docker systemd[1]: Started Docker Application Container Engine.
Hint: Some lines were ellipsized, use -l to show in full.
- List current docker version:
[root@docker ~]# docker --version Docker version 1.12.5, build 7392c3b
- List the current docker images (No images are added yet):
[root@docker ~]# docker -h
Usage: docker [OPTIONS] COMMAND [arg...]
docker [ --help | -v | --version ]
A self-sufficient runtime for containers.
Options:
--config=~/.docker Location of client config files
-D, --debug Enable debug mode
-H, --host=[] Daemon socket(s) to connect to
-h, --help Print usage
-l, --log-level=info Set the logging level
--tls Use TLS; implied by --tlsverify
--tlscacert=~/.docker/ca.pem Trust certs signed only by this CA
--tlscert=~/.docker/cert.pem Path to TLS certificate file
--tlskey=~/.docker/key.pem Path to TLS key file
--tlsverify Use TLS and verify the remote
-v, --version Print version information and quit
Commands:
attach Attach to a running container
build Build an image from a Dockerfile
commit Create a new image from a container's changes
cp Copy files/folders between a container and the local filesystem
create Create a new container
diff Inspect changes on a container's filesystem
events Get real time events from the server
exec Run a command in a running container
export Export a container's filesystem as a tar archive
history Show the history of an image
images List images
import Import the contents from a tarball to create a filesystem image
info Display system-wide information
inspect Return low-level information on a container, image or task
kill Kill one or more running containers
load Load an image from a tar archive or STDIN
login Log in to a Docker registry.
logout Log out from a Docker registry.
logs Fetch the logs of a container
network Manage Docker networks
node Manage Docker Swarm nodes
pause Pause all processes within one or more containers
port List port mappings or a specific mapping for the container
ps List containers
pull Pull an image or a repository from a registry
push Push an image or a repository to a registry
rename Rename a container
restart Restart a container
rm Remove one or more containers
rmi Remove one or more images
run Run a command in a new container
save Save one or more images to a tar archive (streamed to STDOUT by default)
search Search the Docker Hub for images
service Manage Docker services
start Start one or more stopped containers
stats Display a live stream of container(s) resource usage statistics
stop Stop one or more running containers
swarm Manage Docker Swarm
tag Tag an image into a repository
top Display the running processes of a container
unpause Unpause all processes within one or more containers
update Update configuration of one or more containers
version Show the Docker version information
volume Manage Docker volumes
wait Block until a container stops, then print its exit code
Run 'docker COMMAND --help' for more information on a command.
[root@docker ~]# docker help images
Usage: docker images [OPTIONS] [REPOSITORY[:TAG]]
List images
Options:
-a, --all Show all images (default hides intermediate images)
--digests Show digests
-f, --filter value Filter output based on conditions provided (default [])
--format string Pretty-print images using a Go template
--help Print usage
--no-trunc Don't truncate output
-q, --quiet Only show numeric IDs
[root@docker ~]# docker -h | grep images
images List images
- It is not good idea to deal with docker as "root" user, as usually developers and so many people will use docker. The best action to have required people to deal with docker using their accounts:
1. Try to list docker images using "user" account, you will see the following error message:
[user@docker ~]$ docker images Cannot connect to the Docker daemon. Is the docker daemon running on this host?
2. Checking the docker socket file shows that it is owned by "docker" group which has now users:
[root@docker ~]# ls -lh /var/run/docker.sock srw-rw----. 1 root docker 0 Dec 26 18:05 /var/run/docker.sock
[root@docker ~]# grep docker /etc/group docker:x:988:
3. Add "user" username to "docker group and then try again ( You will see the same error message again):
[root@docker ~]# usermod -a -G docker user
[root@docker ~]# grep docker /etc/group docker:x:988:user
[user@docker ~]$ docker images Cannot connect to the Docker daemon. Is the docker daemon running on this host?
4. You need to logout "user" username and login again, then you will be able to list docker images:
[user@docker ~]$ exit [abdo@abdo-base ~]$ ssh user@docker-server [user@docker ~]$ docker images REPOSITORY TAG IMAGE ID CREATED SIZE
No comments:
Post a Comment