使用阿里云服务器

本文涉及的产品
云服务器 ECS,每月免费额度200元 3个月
云服务器ECS,u1 2核4GB 1个月
简介: 操作步骤

尝试基于ECS快速搭建docker环境

image-20210618223452399

image-20210618223539027

image-20210618223624125

image-20210618223650264

ECS云服务器新手上路

image-20210619103343896

image-20210619103400085

image-20210619103431630

下面尝试部署了一下继恩的vue和nginx

nginx使用挂载的方式-v 来实现对容器内部nginx配置文件的替换,

利用docker cp 来把dist文件拷贝进去

使用-p 的方式替换端口

root@yourtreedad:~# docker pull nginx

Using default tag: latest

latest: Pulling from library/nginx

b4d181a07f80: Already exists

66b1c490df3f: Pull complete

d0f91ae9b44c: Pull complete

baf987068537: Pull complete

6bbc76cbebeb: Pull complete

32b766478bc2: Pull complete

Digest: sha256:353c20f74d9b6aee359f30e8e4f69c3d7eaea2f610681c4a95849a2fd7c497f9

Status: Downloaded newer image for nginx:latest

docker.io/library/nginx:latest

root@yourtreedad:~#

root@yourtreedad:~# docker images

REPOSITORY               TAG                 IMAGE ID            CREATED             SIZE

nginx                    latest              4cdc5dd7eaad        10 days ago         133MB

yourtreedad/blazordemo   latest              aa1397c0af05        2 weeks ago         207MB

mysql                    latest              5c62e459e087        3 weeks ago         556MB

root@yourtreedad:~# cd ..

root@yourtreedad:/# pwd

/

root@yourtreedad:/# cd home

root@yourtreedad:/home# ls

blazortest    haierDemo  ljs      mvcwindowstest  nginx      tomcat

consoletest1  kuangshen  mvctest  mysql           nginxdemo  webapitest

root@yourtreedad:/home# cd nginxdemo

root@yourtreedad:/home/nginxdemo# ls

nginx-1.14.2  nginx-1.14.2.zip

root@yourtreedad:/home/nginxdemo# cd nginx-1.14.2

root@yourtreedad:/home/nginxdemo/nginx-1.14.2# ls

conf  contrib  dist  docs  html  logs  nginx.exe  temp

root@yourtreedad:/home/nginxdemo/nginx-1.14.2/conf# docker run --name nginxdemo2 -p 8889:8765 -v /home/nginxdemo/nginx-1

.14.2/conf/myconf1.conf:/etc/nginx/nginx.conf:ro -d nginx

6bed1ace8c9942f62e61ea18f7f632973fa1d7536ac3a6d1ada11e3d2c093b6e

root@yourtreedad:/home/nginxdemo/nginx-1.14.2/conf# docker cp /home/nginxdemo/nginx-1.14.2/dist 6bed1ace8c9942f62e:/etc/nginx

root@yourtreedad:/home/nginxdemo/nginx-1.14.2/conf# docker exec -it 6bed1ace8c9942f62e61ea18f7f632973fa1d7536ac3a6d1ada11e3d2c093b6e /bin/bash

ls

ls

root@6bed1ace8c99:/# ls

bin   docker-entrypoint.d   home   media  proc  sbin  tmp

boot  docker-entrypoint.sh  lib    mnt    root  srv   usr

dev   etc                   lib64  opt    run   sys   var

root@6bed1ace8c99:/# cd /etc

root@6bed1ace8c99:/etc# cd nginx

root@6bed1ace8c99:/etc/nginx# ls

conf.d  dist  fastcgi_params  mime.types  modules  nginx.conf  scgi_params  uwsgi_params

root@6bed1ace8c99:/etc/nginx# cat nginx.conf

#user  nobody;

c553c6ba5f13: Pushed

#error_log  logs/error.log;

#error_log  logs/error.log  notice;

Head https://registry-1.docker.io/v2/yourtreedad/nginxcontaindist/blobs/sha256:4d7903a7ce4bdf92461e0dd87d1fb712facb6881df3cbce68f55f4ec54791546: dial tcp: lookup registry-1.docker.io on 192.168.65.5:53: no such host

root@yourtreedad:/home/nginxdemo/nginx-1.14.2/conf#

events {

   worker_connections  1024;

}

http {

   include       mime.types;

   default_type  application/octet-stream;

   #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '

   #                  '$status $body_bytes_sent "$http_referer" '

   #                  '"$http_user_agent" "$http_x_forwarded_for"';

   #access_log  logs/access.log  main;

   # server {

   #     listen 8765;

   #     listen localhost;

   #     location / {

   #         root dist;

   #         index index.html index.htm;

   #     }

   # }

   sendfile        on;

   #tcp_nopush     on;

   #keepalive_timeout  0;

   keepalive_timeout  65;

   #gzip  on;

   server {

       listen       8765;

       server_name  localhost;

       #charset koi8-r;

       #access_log  logs/host.access.log  main;

       location / {

           root   dist;

           index  index.html index.htm;

       }

       #error_page  404              /404.html;

       # redirect server error pages to the static page /50x.html

       #

       error_page   500502503504  /50x.html;

       location = /50x.html {

           root   html;

       }

       # proxy the PHP scripts to Apache listening on 127.0.0.1:80

       #

       #location ~ \.php$ {

       #    proxy_pass   http://127.0.0.1;

       #}

       # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

       #

       #location ~ \.php$ {

       #    root           html;

       #    fastcgi_pass   127.0.0.1:9000;

       #    fastcgi_index  index.php;

       #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;

       #    include        fastcgi_params;

       #}

67f2e8eb8c87: Pushing [>                                                  ]  77.82kB/4.758MB

       # concurs with nginx's one

       #

       #location ~ /\.ht {

       #    deny  all;

       #}

   }

   # another virtual host using mix of IP-, name-, and port-based configuration

   #

   #server {

   #    listen       8000;

   #    listen       somename:8080;

   #    server_name  somename  alias  another.alias;

   #    location / {

   #        root   html;

   #        index  index.html index.htm;

   #    }

   #}

   # HTTPS server

   #

   #server {

   #    listen       443 ssl;

   #    server_name  localhost;

   #    ssl_certificate      cert.pem;

   #    ssl_certificate_key  cert.key;

   #    ssl_session_cache    shared:SSL:1m;

   #    ssl_session_timeout  5m;

   #    ssl_ciphers  HIGH:!aNULL:!MD5;

   #    ssl_prefer_server_ciphers  on;

   #    location / {

   #        root   html;

   #        index  index.html index.htm;

   #    }

   #}

}

root@6bed1ace8c99:/etc/nginx# exit

exit

root@yourtreedad:/home/nginxdemo/nginx-1.14.2/conf# docker commit -a="yourtreedad" -m="jien's ui add ljs's deploy new nginx that contains dist" 6bed1ace8c nginx:1.0

sha256:4d7903a7ce4bdf92461e0dd87d1fb712facb6881df3cbce68f55f4ec54791546

root@yourtreedad:/home/nginxdemo/nginx-1.14.2/conf# docker push yourtreedad/nginx:1.0

The push refers to repository [docker.io/yourtreedad/nginx]

An image does not exist locally with the tag: yourtreedad/nginx

root@yourtreedad:/home/nginxdemo/nginx-1.14.2/conf# docker tag nginx:1.0 yourtreedad/nginxcontaindist:1.0

root@yourtreedad:/home/nginxdemo/nginx-1.14.2/conf# docker push yourtreedad/nginxcontaindist:1.0

The push refers to repository [docker.io/yourtreedad/nginxcontaindist]

67f2e8eb8c87: Preparing

9d1af766c818: Preparing

d97733c0a3b6: Preparing

c553c6ba5f13: Preparing

48b4a40de359: Preparing

ace9ed9bcfaf: Waiting

764055ebc9a7: Waiting

这是部署在本地 , 现在开始演示部署到云服务器上

image-20210718003213326

通过ssh把配置文件传进去

image-20210718003244110

从dockerhub上拉取镜像

image-20210718003546820

image-20210718003653954

http://47.106.218.61:8888/


相关实践学习
一小时快速掌握 SQL 语法
本实验带您学习SQL的基础语法,快速入门SQL。
7天玩转云服务器
云服务器ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,可降低 IT 成本,提升运维效率。本课程手把手带你了解ECS、掌握基本操作、动手实操快照管理、镜像管理等。了解产品详情: https://www.aliyun.com/product/ecs
相关文章
|
7月前
|
存储 弹性计算 大数据
阿里云服务器的介绍和使用
阿里云服务器的介绍和使用
|
9月前
|
存储 机器学习/深度学习 弹性计算
阿里云服务器是什么?
阿里云服务器是什么? 阿里云服务器全方位介绍包括云服务器ECS优势、云服务器租用价格、云服务器使用场景及限制说明,阿里云服务器网分享云服务器ECS介绍、个人和企业免费试用、云服务器活动、云服务器ECS规格
54 0
|
9月前
|
存储 机器学习/深度学习 弹性计算
为什么要用阿里云服务器呢?
为什么要用阿里云服务器呢?
|
9月前
|
存储 机器学习/深度学习 弹性计算
阿里云服务器介绍
阿里云服务器全方位介绍包括云服务器ECS优势、云服务器租用价格、云服务器使用场景及限制说明,阿里云服务器网分享云服务器ECS介绍、个人和企业免费试用、云服务器活动、云服务器ECS规格、优势、功能及应用场景详细你说明
|
9月前
|
存储 弹性计算 负载均衡
阿里云服务器是什么?
阿里云服务器是什么?云服务器ECS是一种安全可靠、弹性可伸缩的云计算服务,云服务器可以降低IT成本提升运维效率,免去企业或个人前期采购IT硬件的成本,阿里云服务器让用户像使用水、电、天然气等公共资源一样便捷、高效地使用服务器
|
11月前
|
数据采集 机器学习/深度学习 弹性计算
使用阿里云服务器可以哪些事情?
使用阿里云服务器可以哪些事情?使用阿里云服务器可以做什么?阿里云百科分享使用阿里云服务器常用的十大使用场景,说是十大场景实际上用途有很多,阿里云百科分享常见的云服务器使用场景,如本地搭建ChatGPT、个人网站或博客、运维测试、学习Linux、跑Python、小程序服务器等等,云服务器吧分享使用阿里云服务器可以做的几件小事
|
11月前
|
数据采集 机器学习/深度学习 弹性计算
阿里云服务器是干什么用的?
阿里云服务器是干什么用的?使用阿里云服务器可以做什么?阿里云百科分享使用阿里云服务器常用的十大使用场景,说是十大场景实际上用途有很多,阿里云百科分享常见的云服务器使用场景,如本地搭建ChatGPT、个人网站或博客、运维测试、学习Linux、跑Python、小程序服务器等等,云服务器吧分享使用阿里云服务器可以做的几件小事
155 0
|
存储 弹性计算 安全
阿里云服务器介绍详细说明
阿里云服务器安全可靠、弹性可伸缩,CPU可选256核、内存选到3072GB,云服务器ECS规格通用型、计算型、内存型、通用算力型、裸金属、GPU、大数据等ECS实例规格,公网带宽可选到200M,绑定弹性公网EIP带宽可达1000M,共享带宽可达20000M,阿里云百科来详细说下阿里云服务器怎么样?云服务器性能评测以及使用教程:
807 0
阿里云服务器介绍详细说明
|
存储 弹性计算 安全
阿里云服务器怎么样?详细说明
阿里云服务器安全可靠、弹性可伸缩,CPU可选256核、内存选到3072GB,云服务器ECS规格通用型、计算型、内存型、通用算力型、裸金属、GPU、大数据等ECS实例规格,公网带宽可选到200M,绑定弹性公网EIP带宽可达1000M,共享带宽可达20000M,阿里云百科来详细说下阿里云服务器怎么样?云服务器性能评测以及使用教程:
181 0
阿里云服务器怎么样?详细说明
|
弹性计算 安全 Linux
阿里云服务器
阿里云服务器很高兴在这里发表一篇文章来跟大家分享我最近使用ECS的体验感受。我是河南理工大学电子信息专业的一名学生,由于最近所学习的内容的需要,我需要拥有一台稳定安全的服务器。通过了解,我选择了阿里云服务器ECS。这款服务器既好用又强悍,强悍之处在于,它可以让我随时随地的控制着服务器上的电脑。并且我将自己开发的系统部署在这个云服务器上,然后我可以在任何地方、任何时候只需通过访问云服务器所设置网址来访问我开发的系统,非常的方便。
153 0
阿里云服务器