pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

<tfoot id='qsTvW'></tfoot>

      • <bdo id='qsTvW'></bdo><ul id='qsTvW'></ul>
    1. <legend id='qsTvW'><style id='qsTvW'><dir id='qsTvW'><q id='qsTvW'></q></dir></style></legend>

      <i id='qsTvW'><tr id='qsTvW'><dt id='qsTvW'><q id='qsTvW'><span id='qsTvW'><b id='qsTvW'><form id='qsTvW'><ins id='qsTvW'></ins><ul id='qsTvW'></ul><sub id='qsTvW'></sub></form><legend id='qsTvW'></legend><bdo id='qsTvW'><pre id='qsTvW'><center id='qsTvW'></center></pre></bdo></b><th id='qsTvW'></th></span></q></dt></tr></i><div class="r7dxxlb" id='qsTvW'><tfoot id='qsTvW'></tfoot><dl id='qsTvW'><fieldset id='qsTvW'></fieldset></dl></div>
      1. <small id='qsTvW'></small><noframes id='qsTvW'>

        如何在 docker 容器中使用 gulp 運行 livereload?

        How to run livereload with gulp within a docker container?(如何在 docker 容器中使用 gulp 運行 livereload?)
          <tbody id='thwbp'></tbody>
        <i id='thwbp'><tr id='thwbp'><dt id='thwbp'><q id='thwbp'><span id='thwbp'><b id='thwbp'><form id='thwbp'><ins id='thwbp'></ins><ul id='thwbp'></ul><sub id='thwbp'></sub></form><legend id='thwbp'></legend><bdo id='thwbp'><pre id='thwbp'><center id='thwbp'></center></pre></bdo></b><th id='thwbp'></th></span></q></dt></tr></i><div class="jtl5hxv" id='thwbp'><tfoot id='thwbp'></tfoot><dl id='thwbp'><fieldset id='thwbp'></fieldset></dl></div>

        <small id='thwbp'></small><noframes id='thwbp'>

          <tfoot id='thwbp'></tfoot><legend id='thwbp'><style id='thwbp'><dir id='thwbp'><q id='thwbp'></q></dir></style></legend>
          • <bdo id='thwbp'></bdo><ul id='thwbp'></ul>

                1. 本文介紹了如何在 docker 容器中使用 gulp 運行 livereload?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  我創(chuàng)建了一個 docker 容器來使用 gulp 運行任務.所有任務都在運行,問題是我無法在 Chrome 中啟用 livrereload,盡管我在容器中暴露了 35729 端口.

                  I created a docker container to run tasks with gulp. All tasks are running, the problem is I can't enable livrereload in Chrome although I exposed the 35729 port in my container.

                  這里是 Dockerfile:

                  Here is the Dockerfile :

                  FROM ubuntu:latest
                  MAINTAINER jiboulex
                  
                  EXPOSE 80 8080 3000 35729
                  
                  RUN apt-get update
                  RUN apt-get install curl -y
                  RUN apt-get install software-properties-common -y
                  RUN add-apt-repository ppa:chris-lea/node.js
                  RUN apt-get update
                  RUN apt-get install nodejs -y
                  RUN curl -L https://www.npmjs.com/install.sh | sh
                  RUN npm install --global gulp -y
                  
                  # overwrite this with 'CMD []' in a dependent Dockerfile
                  CMD ["/bin/bash"]
                  

                  我使用以下命令創(chuàng)建圖像:

                  I create the image with the following command :

                  docker build -t gulp_image .
                  

                  我創(chuàng)建了一個容器:

                  docker run --name=gulp_container -i -t  --rm  -v /var/www/my_app:/var/www/my_app:rw gulp_image bash
                  

                  然后在我的容器中

                  cd /var/www/my_app
                  gulp
                  

                  這是我的 Gulpfile.js

                  Here is my Gulpfile.js

                  var gulp = require('gulp'),
                  livereload = require('gulp-livereload'),
                  exec = require('child_process').exec;
                  gulp.task('js', function() {
                  gulp.src([
                      './src/js/*.js'
                  ]).pipe(livereload());
                  });
                  gulp.task('watch', function(){
                  var onChange = function (event) {
                      console.log('File '+event.path+' has been '+event.type);
                  };
                  livereload.listen();
                  gulp.watch([
                      './src/js/*.js'
                  ], ['js'])
                      .on('change', onChange);
                  });
                  gulp.task('default', ['watch', 'js']);
                  

                  當我編輯一個 js 文件時,我可以在我的容器中看到文件已被處理,但是當我嘗試在我的瀏覽器 (Chrome) 中啟用實時重新加載時,我收到以下消息:無法連接到 LiveReload 服務器.."

                  When I edit a js file, I can see in my container that the files are processed but when I try to enable live reload in my browser (Chrome), I got the following message : "Could not connect to LiveReload server.."

                  有人知道我錯過了什么或沒有做什么嗎?感謝閱讀!

                  Anyone got a clue about what I missed or didn't do ? Thanks for reading !

                  推薦答案

                  在容器中暴露端口并不意味著將在 docker 主機上打開端口.您應該使用 docker run -p 選項.文檔說:

                  Exposing ports in a container does not imply that the ports will be opened on the docker host. You should be using the docker run -p option. The documentation says:

                  -p=[] : 將容器的端口或一系列端口發(fā)布到主機

                  -p=[] : Publish a container?s port or a range of ports to the host

                  格式: ip:hostPort:containerPort |ip::containerPort |hostPort:containerPort |containerPort

                  hostPortcontainerPort 都可以指定為一個端口范圍.

                  Both hostPort and containerPort can be specified as a range of ports.

                  為兩者指定范圍時,范圍內的容器端口數(shù)必須與范圍內的主機端口數(shù)匹配.(例如,-p 1234-1236:1234-1236/tcp)(使用 'docker port' 查看實際映射)

                  When specifying ranges for both, the number of container ports in the range must match the number > of host ports in the range. (e.g., -p 1234-1236:1234-1236/tcp) (use 'docker port' to see the actual mapping)

                  由于您嘗試了 -p containerPort 形式,當您運行 docker run 命令時,docker 會隨機選擇在您的主機(Linux mint)上打開的實際端口.要確定選擇了哪個端口,您必須使用 docker port 命令.

                  Since you tried the -p containerPort form, the actual port opened on your host (Linux mint) was randomly chosen by docker when you run the docker run command. To figure out what port was chosen, you have to use the docker port command.

                  由于不方便,所以應該使用-p hostPort:containerPort形式,并指定hostPort35729.(我還假設您希望端口 80、8080 和 3000 可以以相同的方式訪問)

                  Since this is not convenient, you should use the -p hostPort:containerPort form, and specify that hostPort is 35729. (I also assume you expect ports 80, 8080 and 3000 to be accessible in the same manner)

                  運行容器的命令是:

                  docker run --name=gulp_container -i -t --rm 
                      -v /var/www/my_app:/var/www/my_app:rw 
                      -p 35729:35729 
                      -p 80:80 
                      -p 8080:8080 
                      -p 3000:3000 
                      gulp_image bash
                  

                  處理端口的更簡單方法是在 主機網(wǎng)絡模式下運行 docker 容器.在這種模式下,在容器上打開的任何端口實際上都是在主機網(wǎng)絡接口上打開的(它們實際上都是共享同一個接口).

                  An easier way to deal with ports is to run your docker container in host networking mode. In this mode, any port opened on the container is in fact opened on the host network interface (they are actually both sharing the same interface).

                  然后您將使用以下命令啟動您的容器:

                  You would then start your container with:

                  docker run --name=gulp_container -i -t --rm 
                      -v /var/www/my_app:/var/www/my_app:rw 
                      --net=host  
                      gulp_image bash
                  

                  這篇關于如何在 docker 容器中使用 gulp 運行 livereload?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯(lián)系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Browserify, Babel 6, Gulp - Unexpected token on spread operator(Browserify,Babel 6,Gulp - 傳播運算符上的意外令牌)
                  Is it possible to pass a flag to Gulp to have it run tasks in different ways?(是否可以將標志傳遞給 Gulp 以使其以不同的方式運行任務?)
                  Why do we need to install gulp globally and locally?(為什么我們需要在全局和本地安裝 gulp?)
                  How to run Gulp tasks sequentially one after the other(如何一個接一個地依次運行 Gulp 任務)
                  Stylesheet not loaded because of MIME-type(由于 MIME 類型而未加載樣式表)
                  Visual Studio 2015 crashes when opening Javascript files(打開 Javascript 文件時 Visual Studio 2015 崩潰)
                    <tbody id='i22xc'></tbody>
                    <legend id='i22xc'><style id='i22xc'><dir id='i22xc'><q id='i22xc'></q></dir></style></legend>
                    <i id='i22xc'><tr id='i22xc'><dt id='i22xc'><q id='i22xc'><span id='i22xc'><b id='i22xc'><form id='i22xc'><ins id='i22xc'></ins><ul id='i22xc'></ul><sub id='i22xc'></sub></form><legend id='i22xc'></legend><bdo id='i22xc'><pre id='i22xc'><center id='i22xc'></center></pre></bdo></b><th id='i22xc'></th></span></q></dt></tr></i><div class="7hfvr7n" id='i22xc'><tfoot id='i22xc'></tfoot><dl id='i22xc'><fieldset id='i22xc'></fieldset></dl></div>

                      <bdo id='i22xc'></bdo><ul id='i22xc'></ul>

                      1. <small id='i22xc'></small><noframes id='i22xc'>

                        • <tfoot id='i22xc'></tfoot>
                          • 主站蜘蛛池模板: 广东之窗网| 湖南长沙商标注册专利申请,长沙公司注册代理记账首选美创! | 纯化水设备-纯水设备-超纯水设备-[大鹏水处理]纯水设备一站式服务商-东莞市大鹏水处理科技有限公司 | 昆明网络公司|云南网络公司|昆明网站建设公司|昆明网页设计|云南网站制作|新媒体运营公司|APP开发|小程序研发|尽在昆明奥远科技有限公司 | 仓储笼_仓储货架_南京货架_仓储货架厂家_南京货架价格低-南京一品仓储设备制造公司 | 武汉刮刮奖_刮刮卡印刷厂_为企业提供门票印刷_武汉合格证印刷_现金劵代金券印刷制作 - 武汉泽雅印刷有限公司 | 大数据营销公司_舆情监测软件_上海SEO公司-文军营销官网 | 万博士范文网-您身边的范文参考网站Vanbs.com| 数显恒温培养摇床-卧式/台式恒温培养摇床|朗越仪器 | 净水器代理,净水器招商,净水器加盟-FineSky德国法兹全屋净水 | led太阳能路灯厂家价格_风光互补庭院灯_农村市政工程路灯-中山华可路灯品牌 | 天津热油泵_管道泵_天津高温热油泵-天津市金丰泰机械泵业有限公司【官方网站】 | 台湾阳明固态继电器-奥托尼克斯光电传感器-接近开关-温控器-光纤传感器-编码器一级代理商江苏用之宜电气 | Q361F全焊接球阀,200X减压稳压阀,ZJHP气动单座调节阀-上海戎钛 | 科威信洗净科技,碳氢清洗机,超声波清洗机,真空碳氢清洗机 | 开云(中国)Kaiyun·官方网站 - 登录入口 | 卡诺亚轻高定官网_卧室系统_整家定制_定制家居_高端定制_全屋定制加盟_定制家具加盟_定制衣柜加盟 | 欧美日韩国产一区二区三区不_久久久久国产精品无码不卡_亚洲欧洲美洲无码精品AV_精品一区美女视频_日韩黄色性爱一级视频_日本五十路人妻斩_国产99视频免费精品是看4_亚洲中文字幕无码一二三四区_国产小萍萍挤奶喷奶水_亚洲另类精品无码在线一区 | 钢托盘,钢制托盘,立库钢托盘,金属托盘制造商_南京飞天金属制品实业有限公司 | 德州网站开发定制-小程序开发制作-APP软件开发-「两山开发」 | 地图标注-手机导航电子地图如何标注-房地产商场地图标记【DiTuBiaoZhu.net】 | 运动木地板价格,篮球馆体育运动木地板生产厂家_欧氏地板 | 蓝鹏测控平台 - 智慧车间系统 - 车间生产数据采集与分析系统 | 深圳市索富通实业有限公司-可燃气体报警器 | 可燃气体探测器 | 气体检测仪 | 伟秀电气有限公司-10kv高低压开关柜-高低压配电柜-中置柜-充气柜-欧式箱变-高压真空断路器厂家 | 可程式恒温恒湿试验箱|恒温恒湿箱|恒温恒湿试验箱|恒温恒湿老化试验箱|高低温试验箱价格报价-广东德瑞检测设备有限公司 | 宁波普瑞思邻苯二甲酸盐检测仪,ROHS2.0检测设备,ROHS2.0测试仪厂家 | 郑州大巴车出租|中巴车租赁|旅游大巴租车|包车|郑州旅游大巴车租赁有限公司 | 缓蚀除垢剂_循环水阻垢剂_反渗透锅炉阻垢剂_有机硫化物-郑州威大水处理材料有限公司 | 背压阀|减压器|不锈钢减压器|减压阀|卫生级背压阀|单向阀|背压阀厂家-上海沃原自控阀门有限公司 本安接线盒-本安电路用接线盒-本安分线盒-矿用电话接线盒-JHH生产厂家-宁波龙亿电子科技有限公司 | 伊卡洛斯软装首页-电动窗帘,别墅窗帘,定制窗帘,江浙沪1000+别墅窗帘案例 | YJLV22铝芯铠装电缆-MYPTJ矿用高压橡套电缆-天津市电缆总厂 | 天津货架厂_穿梭车货架_重型仓储货架_阁楼货架定制-天津钢力仓储货架生产厂家_天津钢力智能仓储装备 | 大立教育官网-一级建造师培训-二级建造师培训-造价工程师-安全工程师-监理工程师考试培训 | 中式装修设计_室内中式装修_【云臻轩】中式设计机构 | 深圳办公室装修,办公楼/写字楼装修设计,一级资质 - ADD写艺 | 洛阳防爆合格证办理-洛阳防爆认证机构-洛阳申请国家防爆合格证-洛阳本安防爆认证代办-洛阳沪南抚防爆电气技术服务有限公司 | 成都网站建设制作_高端网站设计公司「做网站送优化推广」 | 欧必特空气能-商用空气能热水工程,空气能热水器,超低温空气源热泵生产厂家-湖南欧必特空气能公司 | 成都APP开发-成都App定制-成都app开发公司-【未来久】 | 电脑刺绣_绣花厂家_绣花章仔_织唛厂家-[源欣刺绣]潮牌刺绣打版定制绣花加工厂家 |