Posts tagged “RHEL

Playing with docker

Today I got some free time to play with Containers and docker on RHEL7, below are some of my notes that I found useful…….

Step 1 Install Docker on RHEL 7

# subscription-manager repos --enable rhel-7-server-extras-rpms
# subscription-manager repos --enable=rhel-7-server-optional-rpms
# yum install docker
# yum install device-mapper-libs device-mapper-event-libs
# systemctl disable firewalld
# systemctl stop firewalld
# systemctl start docker
# systemctl enable docker
# systemctl status docker

Step 2 get an Image:

To get Docker images from a remote registry and add them to your local system, use the docker pull command:

# docker pull <registry>[:<port>]/[<namespace>/]<name>:<tag>

To see the images on your system, type docker images

# docker images

Inspect an image: Run docker inspect

# docker inspect <full/name/of/image>

To remove images you no longer need, use the docker rmi command:

# docker rmi <image name>

If you want to clear out all your images, you could use a command like the following

# docker rmi $(docker images -a -q)

 

Step 3 run a Container:

When you execute a run command, you essentially create a new container from a Docker image. That container consists of the contents of the image, plus additional options you pass on the docker run command line.

docker run \
-d \
--name <name> \
--network=host \
-e TZ="<timezone>" \
-e option="<optioin>" \
-v <path/to/config>:/config \
-v <path/to/temp>:/temp \
-v <path/to/data>:/data \
Image/name

List running containers:

# docker ps

Stop a container:

# docker stop myrhel_httpd

Restart a container:

# docker start myrhel_httpd

To remove containers you no longer need, use the docker rm command

# docker rm <name>

To see a list of containers that are still hanging around your system, run the docker ps -a

Other usefull stuff:

Shell access to the container while it is running:

docker exec -it <name> /bin/bash

See the logs given by the startup script in real time:

docker logs -f <name>

More Info:

https://access.redhat.com/documentation/en/red-hat-enterprise-linux-atomic-host/version-7/getting-started-with-containers/#get_started_with_docker_formatted_container_images

Advertisements

RHEL7 notes

Below are some helpful tips when working with RHEL7. They are not always recommended however sometimes helpful, especially when new to RHEL7…..

Disable dynamic network interface naming:

# vim /etc/default/grub

add the following to GRUB_CMDLINE_LINUX line
“biosdevname=0 net.ifnames=0”

# grub2-mkconfig –output=/boot/grub2/grub.cfg

reboot

Set Hostname:

# hostnamectl set-hostname “hostname”

Disable network manager and firewalld:

# systemctl stop NetworkManager

# systemctl disable NetworkManager

# systemctl stop firewalld

# systemctl disable firewalld

Register with subscription-manager:

# subscription-manager list –available

# subscription-manager attach –pool=

# subscription-manager repos –list

       # subscription-manager repos –disable=*

# subscription-manager repos –enable <repo-name>

      # subscription-manager repos –enable=rhel-7-server-rpms –enable=rhel-7-server-extras-rpms