Skip to content

Commit 84526e2

Browse files
authored
Add files via upload
1 parent c8ca5c7 commit 84526e2

32 files changed

+1249
-0
lines changed

Ansible/Ansible_install_on_RHEL.MD

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#### On RHEL 8.x server
2+
3+
1. Install Python latest version (on Control node and Managed host)
4+
```sh
5+
yum install python3 -y
6+
```
7+
8+
1. By default, python3 is the command to run python commands. to use just python, use "alternatives" command. (on Control node and Managed host)
9+
```sh
10+
alternatives --set python /usr/bin/python3
11+
```
12+
13+
1. Check for Python version
14+
```sh
15+
python --version
16+
```
17+
1. Install python-pip package manager (on Control node)
18+
```sh
19+
yum -y install python3-pip
20+
```
21+
22+
1. Create a new user for ansible administration & grant admin access to the user (on Control node and Managed host)
23+
```sh
24+
useradd ansadmin
25+
passwd ansadmin
26+
```
27+
1. Below command adds ansadmin to sudoers file. But we strongly recommended using "visudo" command if you are aware vi or nano editor. (on Control node and Managed host)
28+
```sh
29+
echo "ansadmin ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
30+
```
31+
1. Using key-based authentication is advised. If you are still at the learning stage use password-based authentication (on Control node and Managed host)
32+
```sh
33+
# sed command replaces "PasswordAuthentication no to yes" without editing file
34+
sed -ie 's/PasswordAuthentication no/PasswordAuthentication yes/' /etc/ssh/sshd_config
35+
sudo service sshd reload
36+
```
37+
38+
#### Install Ansible as a ansadmin user (on Control node)
39+
```sh
40+
su - ansadmin
41+
pip3 install ansible --user
42+
```
43+
Note: Ansible must be installed as a user (here ansadmin)
44+
1. check for ansible version
45+
```sh
46+
ansible --version
47+
```
48+
49+
1. Log in as a ansadmin user on master and generate ssh key (on Control node)
50+
```sh
51+
ssh-keygen
52+
```
53+
1. Copy keys onto all ansible managed hosts (on Control node)
54+
```sh
55+
ssh-copy-id ansadmin@<target-server>
56+
```
57+
### Validation test
58+
59+
1. Create a directory /etc/ansible and create an inventory file called "hosts" add control node IP address in it.
60+
61+
1. Run ansible command as ansadmin user it should be successful (Master)
62+
```sh
63+
ansible all -m ping
64+
```

Ansible/Ansible_installation.MD

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Ansible Installation
2+
3+
Ansible is an open-source automation platform. It is very, very simple to set up and yet powerful. Ansible can help you with configuration management, application deployment, task automation.
4+
5+
### Pre-requisites
6+
7+
1. An AWS EC2 instance (on Control node)
8+
9+
### Installation steps:
10+
#### on Amazon EC2 instance
11+
12+
1. Install python and python-pip
13+
```sh
14+
yum install python
15+
yum install python-pip
16+
```
17+
1. Install ansible using pip check for version
18+
```sh
19+
pip install ansible
20+
ansible --version
21+
```
22+
23+
1. Create a user called ansadmin (on Control node and Managed host)
24+
```sh
25+
useradd ansadmin
26+
passwd ansadmin
27+
```
28+
1. Below command grant sudo access to ansadmin user. But we strongly recommended using "visudo" command if you are aware vi or nano editor. (on Control node and Managed host)
29+
```sh
30+
echo "ansadmin ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
31+
```
32+
33+
1. Log in as a ansadmin user on master and generate ssh key (on Control node)
34+
```sh
35+
sudo su - ansadmin
36+
ssh-keygen
37+
```
38+
1. Copy keys onto all ansible managed hosts (on Control node)
39+
```sh
40+
ssh-copy-id ansadmin@<target-server>
41+
```
42+
43+
1. Ansible server used to create images and store on docker registry. Hence install docker, start docker services and add ansadmin to the docker group.
44+
```sh
45+
yum install docker
46+
47+
# start docker services
48+
service docker start
49+
service docker start
50+
51+
# add user to docker group
52+
usermod -aG docker ansadmin
53+
54+
```
55+
1. Create a directory /etc/ansible and create an inventory file called "hosts" add control node and managed hosts IP addresses to it.
56+
57+
### Validation test
58+
59+
60+
1. Run ansible command as ansadmin user it should be successful (Master)
61+
```sh
62+
ansible all -m ping
63+
```

Docker/DockerHub.MD

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
## What is Docker Hub Registry
2+
3+
Docker Hub is a cloud-based registry service which allows you to link to code repositories, build your images and test them, stores manually pushed images, and links to Docker Cloud so you can deploy images to your hosts. It provides a centralized resource for container image discovery, distribution and change management, user and team collaboration, and workflow automation throughout the development pipeline.
4+
5+
##### Ref URL : https://docs.docker.com/docker-hub/
6+
7+
1. Create a docker hub account in https://hub.docker.com/
8+
9+
1. Pull a docker image
10+
11+
```sh
12+
docker pull ubuntu
13+
```
14+
15+
1. pull a docker image with the old version
16+
17+
```sh
18+
docker pull ubuntu:16.04
19+
```
20+
21+
1. create a custom tag to the docker image
22+
```sh
23+
docker tag ubuntu:latest valaxy/ubuntu:demo
24+
```
25+
26+
1. login to your docker hub registry
27+
```sh
28+
docker login
29+
docker push valaxy/ubuntu:demo
30+
```
31+
32+
### testing
33+
34+
1. Remove all images in docker server
35+
```sh
36+
docker image rm -f <Image_id>
37+
```
38+
39+
1. Pull your custom image from your docker account
40+
```sh
41+
docker pull valaxy/ubuntu:demo
42+
```
43+

Docker/Docker_Commands.MD

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
2+
1. how to search a docker image in hub.docker.com
3+
```sh
4+
docker search httpd
5+
```
6+
2. Download a docker image from hub.docker.com
7+
```sh
8+
docker image pull <image_name>:<image_version/tag>
9+
```
10+
11+
3. List out docker images from your local system
12+
```sh
13+
docker image ls
14+
```
15+
16+
4. Create/run/start a docker container from image
17+
```sh
18+
docker run -d --name <container_Name> <image_name>:<image_version/tag>
19+
20+
d - run your container in back ground (detached)
21+
```
22+
23+
5. Expose your application to host server
24+
```sh
25+
docker run -d -p <host_port>:<container_port> --name <container_Name> <image_name>:<Image_version/tag>
26+
27+
docker run -d --name httpd_server -p 8080:80 httpd:2.2
28+
```
29+
30+
6. List out running containers
31+
```sh
32+
docker ps
33+
```
34+
35+
7. List out all docker container (running, stpooed, terminated, etc...)
36+
```sh
37+
docker ps -a
38+
```
39+
40+
8. run a OS based container which interactive mode (nothing but login to container after it is up and running)
41+
42+
```sh
43+
docker run -i -t --name centos_server centos:latest
44+
i - interactive
45+
t - Terminal
46+
```
47+
48+
9. Stop a container
49+
```sh
50+
docker stop <container_id>
51+
```
52+
53+
10. Start a container which is in stopped or exit state
54+
55+
```sh
56+
docker start <container_id>
57+
```
58+
11. Remove a container
59+
60+
```sh
61+
docker rm <container_id>
62+
```
63+
64+
12. login to a docker container
65+
```sh
66+
docker exec -it <container_Name> /bin/bash
67+
```

Docker/Docker_Installation_Steps.MD

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Installing Docker on Amazon Linux server
2+
3+
### Pre-requisites
4+
1. Amazon Linux EC2 Instance
5+
6+
## Installation Steps
7+
8+
1. Install docker and start docker services
9+
```sh
10+
yum install docker -y
11+
docker --version
12+
13+
# start docker services
14+
service docker start
15+
service docker status
16+
```
17+
1. Create a user called dockeradmin
18+
```sh
19+
useradd dockeradmin
20+
passwd dockeradmin
21+
```
22+
1. add a user to docker group to manage docker
23+
```
24+
usermod -aG docker dockeradmin
25+
```
26+
### Validation test
27+
1. Create a tomcat docker container by pulling a docker image from the public docker registry
28+
```sh
29+
docker run -d --name test-tomcat-server -p 8090:8080 tomcat:latest
30+
```
31+
32+
## Docker Installation on CentOS server
33+
##### Referance URL : https://docs.docker.com/install/linux/docker-ce/centos/#install-using-the-repository
34+
### Pre-requisites
35+
36+
Please follow below steps to install docker CE on CentoOS server instance. For RedHat only Docker EE available
37+
38+
1. Install the required packages.
39+
40+
```sh
41+
sudo yum install -y yum-utils \
42+
device-mapper-persistent-data \
43+
lvm2
44+
```
45+
46+
1. Use the following command to set up the stable repository.
47+
48+
```sh
49+
sudo yum-config-manager \
50+
--add-repo \
51+
https://download.docker.com/linux/centos/docker-ce.repo
52+
```
53+
54+
### INSTALLING DOCKER CE
55+
56+
1. Install the latest version of Docker CE.
57+
```sh
58+
sudo yum install docker-ce
59+
```
60+
61+
Note: If prompted to accept the GPG key, verify that the fingerprint matches
62+
060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35, and if so, accept it.
63+
64+
1. Start Docker.
65+
```sh
66+
sudo systemctl start docker
67+
```
68+
69+
1. Verify that docker is installed correctly by running the hello-world image.
70+
```sh
71+
sudo docker run hello-world
72+
```

Docker/Dockerfile_Instructions.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
2+
DockerFile
3+
4+
1. A Dockerfile is a text document that contains all the commands a user could call on the command line to assemble an image.
5+
2. The docker build command builds an image from a Dockerfile and a context.
6+
```sh
7+
docker build .
8+
docker build -f /path/to/a/Dockerfile .
9+
docker build -t shykes/myapp .
10+
```
11+
12+
3. The Docker daemon runs the instructions in the Dockerfile one-by-one, committing the result of each instruction to a new image if necessary, before finally outputting the ID of your new image.
13+
4. Whenever possible, Docker uses a build-cache to accelerate the docker build process significantly.
14+
5. When you’re done with your build, you’re ready to look into scanning your image with docker scan
15+
```sh
16+
docker scan hello-world
17+
18+
```
19+
20+
## Dockerfile Creation
21+
22+
Docker file format
23+
```sh
24+
# Comment
25+
INSTRUCTION arguments
26+
```
27+
28+
1. A Dockerfile must begin with a FROM instruction.
29+
30+
2. Docker distributes official versions of the images that can be used for building Dockerfiles under docker/dockerfile repository on Docker Hub.
31+
32+
- `FROM` - A valid Dockerfile must start with a FROM instruction.
33+
34+
- `RUN` - The RUN instruction will execute any commands in a new layer on top of the current image and commit the results. The resulting committed image will be used for the next step in the Dockerfile.
35+
36+
- `CMD` - The main purpose of a CMD is to provide defaults for an executing container.
37+
38+
`Note:` There can only be one CMD instruction in a Dockerfile. If you list more than one CMD then only the last CMD will take effect.
39+
40+
`Note` - Do not confuse RUN with CMD. RUN actually runs a command and commits the result; CMD does not execute anything at build time, but specifies the intended command for the image.
41+
42+
- `LABEL` -The LABEL instruction adds metadata to an image. A LABEL is a key-value pair. T
43+
44+
- `EXPOSE`
45+
1. The EXPOSE instruction informs Docker that the container listens on the specified network ports at runtime.
46+
2. To set up port redirection on the host system, see using the -P flag.
47+
3. The docker network command supports creating networks for communication among containers without the need to expose or publish specific ports, because the containers connected to the network can communicate with each other over any port.
48+
49+
- `ENV` - The ENV instruction sets the environment variable <key> to the value <value>.
50+
51+
- `ADD` - The ADD instruction copies new files, directories or remote file URLs from <src> and adds them to the filesystem of the image at the path <dest>.
52+
53+
If <src> is a local tar archive in a recognized compression format (identity, gzip, bzip2 or xz) then it is unpacked as a directory.
54+
55+
- `COPY` - The COPY instruction copies new files or directories from <src> and adds them to the filesystem of the container at the path <dest>.
56+
57+
- `ENTRYPOINT` - An ENTRYPOINT allows you to configure a container that will run as an executable.
58+
59+
1. ENTRYPOINT will override all elements specified using CMD
60+
2. Both CMD and ENTRYPOINT instructions define what command gets executed when running a container. There are few rules that describe their co-operation.
61+
62+
3. Dockerfile should specify at least one of CMD or ENTRYPOINT commands.
63+
64+
4. ENTRYPOINT should be defined when using the container as an executable.
65+
66+
5. CMD should be used as a way of defining default arguments for an ENTRYPOINT command or for executing an ad-hoc command in a container.
67+
68+
6. CMD will be overridden when running the container with alternative arguments.
69+
70+
- `VOLUME` - The VOLUME instruction creates a mount point with the specified name and marks it as holding externally mounted volumes from native host or other containers.
71+
72+
- `USER` - The USER instruction sets the user name to use when running the image
73+
- `WORKDIR` - The WORKDIR instruction sets the working directory for any RUN, CMD, ENTRYPOINT, COPY and ADD instructions
74+
75+
- `ARG` - The ARG instruction defines a variable that users can pass at build-time to the builder with the docker build command using the --build-arg <varname>=<value> flag.
76+
77+
- `SHELL` - The SHELL instruction allows the default shell used for the shell form of commands to be overridden.
78+
79+

0 commit comments

Comments
 (0)