# Запрос
GET /blog HTTP/1.1
Host: smartiqa.ru
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:18.0) Gecko/20100101 Firefox/18.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Cookie: wp-settings
Connection: keep-alive
# Ответ
HTTP/1.1 200 OK
Date: Sun, 10 Feb 2013 03:51:41 GMT
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
Keep-Alive: timeout=5
Server: Apache
<!DOCTYPE html PUBLIC «-//W3C//DTD XHTML 1.0 Transitional//EN» «http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd»>
<html xmlns=»http://www.w3.org/1999/xhtml»>
<head>
<meta http-equiv=»Content-Type» content=»text/html; charset=utf-8″ />
<title>Smartiqa Blog</title>
</head>
<body>
</body>
</html>
tati@tati ~ % ls /dev
afsc_type5 ptyw7
auditpipe ptyw8
auditsessions ptyw9
autofs ptywa
autofs_control ptywb
autofs_homedirmounter ptywc
autofs_notrigger ptywd
autofs_nowait ptywe
bpf0 ptywf
bpf1 'random'
bpf2 rdisk0
bpf3 rdisk0s1
console rdisk0s2
cu.BLTH rdisk1
cu.Bluetooth-Incoming-Port rdisk1s2
'disk0' rdisk1s3
disk0s1 rdisk1s4
disk0s2 rdisk1s5
'disk1' rdisk1s6
disk1s2 rdisk1s7
disk1s3 rdisk1s7s1
disk1s4 sdt
disk1s5 'stderr'
disk1s6 'stdin'
disk1s7 'stdout'
disk1s7s1 systrace
dtrace tty
dtracehelper tty.BLTH
fbt tty.Bluetooth-Incoming-Port
fd ttyp0
fsevents ttyp1
machtrace ttyp7
'null' ttyp8
oslog ttyp9
oslog_stream ttypa
pf ttypb
pfm ttypc
profile ttypd
ptmx ttype
ptyp0 ttypf
ptyp1 ttyq0
ptyp2 ttyq1
ptyp3 ttyq2
<...>
ptyw2 uart.BLTH
ptyw3 'urandom'
ptyw4 xcpm
ptyw5 zero
ptyw6
# Active Internet connections
Proto Recv-Q Send-Q Local Address Foreign Address (state)
tcp4 0 0 192.168.0.104.59152 stackoverflow.co.https ESTABLISHED
tcp4 0 0 192.168.0.104.59149 199.232.148.193.https ESTABLISHED
tcp4 0 0 192.168.0.104.59148 192.0.73.2.https ESTABLISHED
tcp4 0 0 192.168.0.104.59147 151.101.129.69.https ESTABLISHED
tcp4 0 517 192.168.0.104.59145 lb-in-f113.1e100.https ESTABLISHED
tcp4 0 517 192.168.0.104.59142 lb-in-f113.1e100.https ESTABLISHED
tcp4 0 0 192.168.0.104.59141 lu-in-f101.1e100.https ESTABLISHED
tcp4 0 0 192.168.0.104.59140 rest-domains.hh..https ESTABLISHED
tcp4 0 0 192.168.0.104.59139 la-in-f18.1e100..https ESTABLISHED
tcp4 0 517 192.168.0.104.59138 lb-in-f113.1e100.https ESTABLISHED
tcp4 0 517 192.168.0.104.59137 lb-in-f113.1e100.https ESTABLISHED
# Active Multipath Internet connections
Proto/ID Flags Local Address Foreign Address (state)
icm6 0 0 *.* *.*
# Active LOCAL (UNIX) domain sockets
Address Type Recv-Q Send-Q Inode Conn Refs Nextref Addr
5e16cedc125c3a1f stream 0 0 0 5e16cedc125c3957 0 0 /var/run/mDNSResponder
5e16cedc125c3957 stream 0 0 0 5e16cedc125c3a1f 0 0
5e16cedc125c41ef stream 0 0 0 5e16cedc125c6f97 0 0 /var/run/mDNSResponder
5e16cedc125c6f97 stream 0 0 0 5e16cedc125c41ef 0 0
5e16cedc125c8c7f stream 0 0 0 5e16cedc125c8bb7 0 0 /var/run/mDNSResponder
5e16cedc125c4a87 dgram 0 0 0 5e16cedc125c94a7 0 5e16cedc125c356f
5e16cedc125c356f dgram 0 0 0 5e16cedc125c94a7 0 5e16cedc125c4447
5e16cedc125c4447 dgram 0 0 0 5e16cedc125c94a7 0 5e16cedc125c37c7
5e16cedc125c37c7 dgram 0 0 0 5e16cedc125c94a7 0 5e16cedc125c34a7
5e16cedc125c34a7 dgram 0 0 0 5e16cedc125c94a7 0 5e16cedc125c4767
===========================================================================
Interface List
0x1 ........................... MS TCP Loopback interface
0x2 ...00 14 2a 8b a1 b5 ...... NVIDIA nForce Networking Controller
0x3 ...00 50 56 c0 00 01 ...... VMware Virtual Ethernet Adapter for VMnet1
0xd0005 ...00 53 45 00 00 00 ...... WAN (PPP/SLIP) Interface
===========================================================================
===========================================================================
Active Routes:
Network Destination Netmask Gateway Interface Metric
0.0.0.0 0.0.0.0 89.223.67.129 89.223.67.131 20
60.48.85.155 255.255.255.255 89.223.67.129 89.223.67.131 20
60.48.105.1 255.255.255.255 89.223.67.129 89.223.67.131 20
60.48.172.103 255.255.255.255 89.223.67.129 89.223.67.131 20
60.48.203.116 255.255.255.255 89.223.67.129 89.223.67.131 20
60.49.71.132 255.255.255.255 89.223.67.129 89.223.67.131 20
66.36.138.228 255.255.255.255 89.223.67.129 89.223.67.131 20
66.36.152.228 255.255.255.255 89.223.67.129 89.223.67.131 20
74.108.102.130 255.255.255.255 89.223.67.129 89.223.67.131 20
89.223.67.128 255.255.255.192 89.223.67.131 89.223.67.131 20
89.223.67.131 255.255.255.255 127.0.0.1 127.0.0.1 20
89.255.255.255 255.255.255.255 89.223.67.131 89.223.67.131 20
127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1 1
164.77.239.153 255.255.255.255 89.223.67.129 89.223.67.131 20
192.168.23.0 255.255.255.0 192.168.23.1 192.168.23.1 20
192.168.23.1 255.255.255.255 127.0.0.1 127.0.0.1 20
192.168.23.255 255.255.255.255 192.168.23.1 192.168.23.1 20
192.168.192.0 255.255.255.0 192.168.192.251 192.168.192.251 1
192.168.192.251 255.255.255.255 127.0.0.1 127.0.0.1 50
192.168.192.255 255.255.255.255 192.168.192.251 192.168.192.251 50
212.113.96.250 255.255.255.255 89.223.67.129 89.223.67.131 20
219.95.153.243 255.255.255.255 89.223.67.129 89.223.67.131 20
224.0.0.0 240.0.0.0 89.223.67.131 89.223.67.131 20
224.0.0.0 240.0.0.0 192.168.23.1 192.168.23.1 20
224.0.0.0 240.0.0.0 192.168.192.251 192.168.192.251 50
255.255.255.255 255.255.255.255 89.223.67.131 89.223.67.131 1
255.255.255.255 255.255.255.255 192.168.23.1 192.168.23.1 1
255.255.255.255 255.255.255.255 192.168.192.251 192.168.192.251 1
Default Gateway: 89.223.67.129
===========================================================================
-- Cоздадим таблицу с названием months и тремя столбцами
CREATE TABLE months (id int, name varchar(10), days_number int);
-- Добавим в таблицу месяц Январь
INSERT INTO months (id,name,days_number) VALUES (0, ‘Junuary’, 31);
-- Простые запросы
SELECT * FROM books;
SELECT name, author FROM books;
SELECT * FROM books ORDER by name DESC
-- Запросы с WHERE
SELECT * FROM books
WHERE author = ‘I. S. Turgenev’;
SELECT * FROM books
WHERE year >= 1900 AND genre == ’Story’;
SELECT * FROM books
WHERE genre IN (’story’, ‘detective’);
SELECT * FROM books
WHERE year BETWEEN 1900 AND 1950;
SELECT * FROM books
WHERE name LIKE ‘K%’;
SELECT count(distinct beers) FROM participant;
-- Запросы с функциями
SELECT MIN(year) FROM books;
SELECT SUM(pages_number) FROM books;
SELECT author, AVG(pages_number) as avg_pages_number FROM books GROUP BY author;
-- Вложенный SELECT
SELECT name, author WHERE year = ( SELECT MIN(year) from books );
-- Соединение таблиц
SELECT books.name, books.year, publisher.name
FROM books INNER JOIN publishers
ON books.publisher_id = publishers.id
-- Оконные функции
SELECT date, cash_flow,
SUM(cash_flow) OVER (ORDER BY date ASC) AS cumulative_cf
FROM transactions;
-- Для всех книг с количеством страниц больше 200 проставим размер big
UPDATE books SET size = ‘big’
WHERE pages_number > 200
Удалим из таблицы все книги, написанные Л. Н. Толстым
DELETE FROM books WHERE author = ‘L. N. Tolstoy’
-- Удалим таблицу books
TRUNCATE TABLE books;
ENV id=48ab5012b
FROM python:3.9
RUN mkdir -p /opt/app
WORKDIR /opt/app
ENV PYTHONPATH /opt/app
RUN pip3 config -v debug
RUN apt-get update
RUN apt-get install -y zbar-tools libzbar-dev zip sshpass openssh-client curl git libssl-dev make iputils-ping xvfb rdesktop
COPY pip.conf /etc/pip.conf
RUN python3 -m venv venv && pip3 install --upgrade pip
COPY selenium/requirements.txt /opt/app/requirements.txt
RUN pip3 install -r requirements.txt
RUN mkdir -p /root/.ssh && \
chmod 700 /root/.ssh && \
touch /root/.ssh/known_hosts && \
chmod 600 /root/.ssh/known_hosts
# -----------
# 1. Run container from alpine image
$ docker container run alpine:latest
Unable to find image 'alpine:latest' locally
latest: Pulling from library/alpine
7264a8db6415: Pull complete
Digest: sha256:7144f7bab3d4c2648d7e59409f15ec52a18006a128c733fcff20d3a4a54ba44a
Status: Downloaded newer image for alpine:latest
# The container ID is 888e89a3b36b. Status is Exited
$ docker container ls --all
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6e34c821672f alpine:latest "/bin/sh" 19 seconds ago Exited (0) 18 seconds ago elegant_wilson
# -----------
# 2. Run interactive container with ubuntu image
# --tty allocates a pseudo-tt
# --rm tells Docker to remove the container when its execution is finished
$ docker container run --interactive --tty --rm ubuntu bash
Unable to find image 'ubuntu:latest' locally
latest: Pulling from library/ubuntu
b237fe92c417: Pull complete
Digest: sha256:ec050c32e4a6085b423d36ecd025c0d3ff00c38ab93a3d71a460ff1c44fa6d77
Status: Downloaded newer image for ubuntu:latest
# Work inside container
root@239247f11f9e:/# ls
bin dev home lib32 libx32 mnt proc run srv tmp var
boot etc lib lib64 media opt root sbin sys usr
root@239247f11f9e:/# cat /etc/issue
Ubuntu 22.04.3 LTS
root@239247f11f9e:/# exit
exit
# Since --rm flag was used, Docker removed the container when it stopped.
$ ls --all
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6e34c821672f alpine:latest "/bin/sh" 16 minutes ago Exited (0) 16 minutes ago elegant_wilson
# -----------
# 3. Run a background MySQL container
# --detach run in the background.
$ docker container run --detach --name mydb -e MYSQL_ROOT_PASSWORD=my-secret-pw mysql:latest
$ docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3899eba0d4f0 mysql:latest "docker-entrypoint.s…" 3 seconds ago Up 3 seconds 3306/tcp, 33060/tcp mydb
# Display the running processes of a container
$ docker container top mydb
PID USER TIME COMMAND
303 999 0:01 mysqld
# Execute cmd inside container with name mydb
$ docker exec -it mydb \
> mysql --user=root --password=$MYSQL_ROOT_PASSWORD --version
mysql: [Warning] Using a password on the command line interface can be insecure.
mysql Ver 8.1.0 for Linux on x86_64 (MySQL Community Server - GPL)
# Connect to a new shell process inside mydb container
$ docker exec -it mydb sh
sh-4.4# ls
bin dev etc lib media opt root sbin sys usr
boot docker-entrypoint-initdb.d home lib64 mnt proc run srv tmp var
sh-4.4#
# -----------
# 4. Run a custom web app and publish it
# Clone repo with app
$ git clone https://github.com/dockersamples/linux_tweet_app
$ cd ~/linux_tweet_app
# Build image from Dockerfile
$ cat Dockerfile
FROM nginx:latest
COPY index.html /usr/share/nginx/html
COPY linux.png /usr/share/nginx/html
EXPOSE 80 443
CMD ["nginx", "-g", "daemon off;"]
$ export DOCKERID=<your_login_to_docker_hub>
$ docker image build --tag $DOCKERID/linux_tweet_app:1.0 .
=> [internal] load build definition from Dockerfile
=> => transferring dockerfile: 186B
=> [internal] load metadata for docker.io/library/nginx:latest
=> [1/3] FROM
=> [2/3] COPY index.html /usr/share/nginx/html
=> [3/3] COPY linux.png /usr/share/nginx/html
=> exporting to image
=> => exporting layers
=> => writing image
=> => naming to docker.io/nocuddles/linux_tweet_app:1.0
# Change the site
$ cp index-new.html index.html
# Build new image file
$ docker image build --tag $DOCKERID/linux_tweet_app:2.0 .
$ docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
<docker_id>/linux_tweet_app 2.0 c22259b0b5c0 19 seconds ago 187MB
<docker_id>/linux_tweet_app 1.0 532a95958384 18 minutes ago 187MB
# Push new image to Docker Hub
$ docker login
$ docker image push $DOCKERID/linux_tweet_app:1.0
$ docker image push $DOCKERID/linux_tweet_app:2.0
# Pull image
docker pull <docker_id>/linux_tweet_app:2.0
# Run container
# Usage: docker container run [OPTIONS] IMAGE [COMMAND] [ARG...]
$ docker container run alpine hostname
$ docker container run --interactive --tty --rm ubuntu bash
$ docker container run --detach --name mydb -e MYSQL_ROOT_PASSWORD=my-secret-pw mysql:latest
$ docker container run --detach --publish 80:80 --name linux_tweet_app $DOCKERID/linux_tweet_app:1.0
$ docker container run --detach --publish 80:80 \
--name linux_tweet_app --mount type=bind,source="$(pwd)",target=/usr/share/nginx/html
$DOCKERID/linux_tweet_app:1.0
# Stop/remove container
# Usage: docker stop [OPTIONS] CONTAINER [CONTAINER...]
$ docker stop <id> # graceful shutdown
$ docker kill <id> # brutal shutdown
$ docker rm <id> # removes container
$ docker rm --force <id> # removes container without shutting down
$ docker run --rm -it Ubuntu /bin/bash # will remove container as soon as it stops
# Kubectl — позволяет создавать и настраивать объекты в кластере
# Kubelet — занимается запуском контейнеров на хостах
# Kubeadm — позволит настраивать компоненты, составляющие кластер
apt-get install -y kubelet kubeadm kubectl
systemctl enable kubelet && systemctl start kubelet
# Инициализация кластера
kubeadm init --pod-network-cidr=10.244.0.0/16
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
# Добавление Ноды в кластер
kubeadm join --token <token> <control-plane-host>:<control-plane-port> --discovery-token-ca-cert-hash sha256:<hash>
syntax = "proto3";
package api;
import "price.proto";
message Product {
message Id {
uint32 value = 1;
}
Id id = 1;
string name = 2;
string text = 3;
string url = 4;
Price price = 5;
}