Docker QuickStart

来自Jack's Lab
(版本间的差异)
跳转到: 导航, 搜索
(Reference)
(Restore Container)
 
(未显示1个用户的6个中间版本)
第224行: 第224行:
  
 
<br><br>
 
<br><br>
 +
 +
== RM image ==
 +
 +
<source lang=bash>
 +
 +
comcat@aisrv:/srv/mqtt/backup$ sudo docker images
 +
REPOSITORY          TAG                IMAGE ID            CREATED            SIZE
 +
autoabc-mqtt        2.1.2              3d232f5b132f        30 minutes ago      29.7MB
 +
mysql              5.7.28              cd3ed0dfff7e        5 months ago        437MB
 +
comcat@aisrv:/srv/mqtt/backup$ sudo docker rmi 3d232
 +
Untagged: mqtt:2.1.2
 +
Deleted: sha256:3d232f5b132fe4a2e6240ced52a3232f20a9b07f610e8e87447967c37a25828e
 +
Deleted: sha256:2302918bc81db19aa4d7ee71521db8ff4eb44d3ab4449c501f7539e88757ef2d
 +
comcat@aisrv:/srv/mqtt/backup$ sudo docker images
 +
REPOSITORY          TAG                IMAGE ID            CREATED            SIZE
 +
mysql              5.7.28              cd3ed0dfff7e        5 months ago        437MB
 +
</source>
 +
 +
<br>
  
 
== Export port ==
 
== Export port ==
第407行: 第426行:
 
$ cat /home/export.tar | sudo docker import - api-elec:latest
 
$ cat /home/export.tar | sudo docker import - api-elec:latest
 
</pre>
 
</pre>
 +
 +
<br>
 +
 +
== Export Image ==
 +
 +
例如我们想将镜像库中的postgres和mongo打包,那么可以执行:
 +
 +
<source lang=bash>
 +
$ sudo docker save -o images.tar postgres:9.6 mongo:3.4
 +
</source>
 +
 +
恢复:
 +
 +
<source lang=bash>
 +
$ sudo docker load -i images.tar
 +
</source>
  
 
<br>
 
<br>

2020年3月21日 (六) 10:20的最后版本

目录

[编辑] 1 Install

New: https://docs.docker.com/install/linux/docker-ce/ubuntu/


Windows:


Ubuntu:

Aliyun (Old):

$ sudo apt-get install docker.io docker-compose
$ sudo usermod -aG docker $USER


加速 docker pull 访问:

In order to speedup docker images downloading, please configure a local docker mirror in /etc/default/docker, for example:

$ grep registry-mirror /etc/default/docker
DOCKER_OPTS="$DOCKER_OPTS --registry-mirror=https://docker.mirrors.ustc.edu.cn"
$ service docker restart

In order to avoid network ip address conflict, please try following changes and restart docker:

$ grep bip /etc/default/docker
DOCKER_OPTS="$DOCKER_OPTS --bip=10.66.0.10/16"
$ service docker restart

If the above changes not work, try something as following:

$ grep dockerd /lib/systemd/system/docker.service
ExecStart=/usr/bin/dockerd -H fd:// --bip=10.66.0.10/16 --registry-mirror=https://docker.mirrors.ustc.edu.cn
$ service docker restart



[编辑] 2 Quick Start

https://cloud.docker.com 免费注册一个 Docker 账号


登录 docker hub:

comcat@icamgo:~$ docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username: noduino
Password:
Login Succeeded


搜索镜像 docker search

comcat@icamgo:~$ docker search mysql
NAME                              DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
mysql                             MySQL is a widely used, open-source relati...   8741      [OK]
mariadb                           MariaDB is a community-developed fork of M...   3063      [OK]
mysql/mysql-server                Optimized MySQL Server Docker images. Crea...   647                  [OK]
centos/mysql-57-centos7           MySQL 5.7 SQL database server                   63
centurylink/mysql                 Image containing mysql. Optimized to be li...   61                   [OK]
mysql/mysql-cluster               Experimental MySQL Cluster Docker images. ...   54
deitch/mysql-backup               REPLACED! Please use http://hub.docker.com...   41                   [OK]
bitnami/mysql                     Bitnami MySQL Docker Image                      35                   [OK]
tutum/mysql                       Base docker image to run a MySQL database ...   34
schickling/mysql-backup-s3        Backup MySQL to S3 (supports periodic back...   28                   [OK]
prom/mysqld-exporter                                                              23                   [OK]
linuxserver/mysql                 A Mysql container, brought to you by Linux...   22
centos/mysql-56-centos7           MySQL 5.6 SQL database server                   16
circleci/mysql                    MySQL is a widely used, open-source relati...   15
mysql/mysql-router                MySQL Router provides transparent routing ...   13
arey/mysql-client                 Run a MySQL client from a docker container      12                   [OK]
imega/mysql-client                Size: 36 MB, alpine:3.5, Mysql client: 10....   8                    [OK]
openshift/mysql-55-centos7        DEPRECATED: A Centos7 based MySQL v5.5 ima...   6
yloeffler/mysql-backup            This image runs mysqldump to backup data u...   6                    [OK]
fradelg/mysql-cron-backup         MySQL/MariaDB database backup using cron t...   4                    [OK]
genschsa/mysql-employees          MySQL Employee Sample Database                  2                    [OK]
ansibleplaybookbundle/mysql-apb   An APB which deploys RHSCL MySQL                2                    [OK]
jelastic/mysql                    An image of the MySQL database server main...   1
monasca/mysql-init                A minimal decoupled init container for mysql    0
widdpim/mysql-client              Dockerized MySQL Client (5.7) including Cu...   0                    [OK]


拉取官方 mysql 镜像 docker pull:

comcat@autoeco:~$ sudo docker pull mysql:5.7.28
5.7.28: Pulling from library/mysql
80369df48736: Pull complete
e8f52315cb10: Pull complete
cf2189b391fc: Pull complete
cc98f645c682: Pull complete
27a27ac83f74: Pull complete
fa1f04453414: Pull complete
d45bf7d22d33: Pull complete
c7d49ffebc56: Pull complete
511a8052b204: Pull complete
5d5df4c12444: Pull complete
d482603a2922: Pull complete
Digest: sha256:44b33224e3c406bf50b5a2ee4286ed0d7f2c5aec1f7fdb70291f7f7c570284dd
Status: Downloaded newer image for mysql:5.7.28
docker.io/library/mysql:5.7.28

# 从 images 启动一个容器实例
$ sudo docker run --name autoeco-mysql -v /srv/mysql5.7:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=YOUR_PASSWD -p 3306:3306 -d mysql:5.7.28 --character-set-server=utf8 --collation-server=utf8_unicode_ci

# 运行中的容器
$ sudo docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                               NAMES
8c17c84ec816        mysql:5.7.28        "docker-entrypoint.sâ¦"   8 minutes ago       Up 5 minutes        0.0.0.0:3306->3306/tcp, 33060/tcp   autoeco-mysql

# 停止容器
$ sudo docker stop 8c17

# 重启容器
$ sudo docker restart 8c17

# 修改配置。先把运行中的容器中 mysql 的配置文件拷贝到本地
$ sudo docker cp 8c17:/etc/mysql/mysql.conf.d/mysqld.cnf .

# 修改后再拷贝回,重启容器即可
$ sudo docker cp  mysql/mysql.conf.d/mysqld.cnf 8c1:/etc/mysql/mysql.conf.d/


如果配置修改调整引起不可知问题,可以把有问题的 docker 实例删除,重新起一个新实例。调试配置时,可将配置目录也映射到本机即可:

$ sudo docker rm 8c17
$ sudo docker run --name autoeco-mysql -v /srv/cfg/mysql:/etc/mysql -v /srv/mysql5.7:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=YOUR_PASSWD -p 3306:3306 -d mysql:5.7.28 --character-set-server=utf8 --collation-server=utf8_unicode_ci

mysql 常见配置选项,参考:https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html


推送你修改后的 mysql 镜像 docker push:

$ docker push {username}/{镜像名}:{tag}



[编辑] 3 Pull image from docker hub

comcat@aisrv:/work/api.noduino/database$ docker pull mysql/mysql-server:5.5
5.5: Pulling from mysql/mysql-server
33a3a5e469a8: Pull complete
afd5b2a51aab: Pull complete
d3fcc85ceffc: Pull complete
9c58bb63c013: Pull complete
Digest: sha256:db8aecdf439d2a5dcc509cca80deabb28a8b7370725d0c71f46957d0e257ffd6
Status: Downloaded newer image for mysql/mysql-server:5.5

comcat@aisrv:/work/api.noduino/database$ docker images
REPOSITORY             TAG                 IMAGE ID            CREATED             SIZE
emqwebhook             20170505            1a2e9eb03836        44 hours ago        33.65 MB
<none>                 <none>              3fc8aea36f2d        46 hours ago        3.994 MB
nginx                  latest              46102226f2fd        10 days ago         109.4 MB
emqttd-docker-v2.1.2   latest              a799525a9a73        2 weeks ago         34.3 MB
mysql/mysql-server     5.5                 89418f92e739        3 weeks ago         168.9 MB
alpine                 3.5                 4a415e366388        9 weeks ago         3.987 MB



[编辑] 4 Run container

comcat@aisrv:/work/api.noduino/database$ docker run --name cos-mysql -e MYSQL_ROOT_PASSWORD=root -d mysql/mysql-server:5.5
beb67efbda72bb356a2630624eff965e89d5477cf7f596176fa45cb036d7db75

comcat@aisrv:/work/api.noduino/database$ docker exec -it cos-mysql mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.55 MySQL Community Server (GPL)

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

comcat@aisrv:/work/api.noduino/database$ docker exec -it cos-mysql bash



[编辑] 5 RM container

comcat@aisrv:/work/api.noduino/database$ docker ps -a
comcat@aisrv:/work/api.noduino/database$ docker rm beb67efbda72
beb67efbda72

comcat@aisrv:/work/api.noduino/database$ docker pull mysql/mysql-server:5.6

comcat@aisrv:/work/api.noduino/database$ docker ps -a
CONTAINER ID        IMAGE                    COMMAND                  CREATED             STATUS                        PORTS               NAMES
987ab5054b83        mysql/mysql-server:5.6   "/entrypoint.sh mysql"   18 minutes ago      Up 18 minutes                 3306/tcp            mysql
52df2e0d29b2        emqttd-docker-v2.1.2     "/opt/emqttd/start.sh"   10 days ago         Exited (137) 45 minutes ago                       emq20



[编辑] 6 RM image


comcat@aisrv:/srv/mqtt/backup$ sudo docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
autoabc-mqtt        2.1.2               3d232f5b132f        30 minutes ago      29.7MB
mysql               5.7.28              cd3ed0dfff7e        5 months ago        437MB
comcat@aisrv:/srv/mqtt/backup$ sudo docker rmi 3d232
Untagged: mqtt:2.1.2
Deleted: sha256:3d232f5b132fe4a2e6240ced52a3232f20a9b07f610e8e87447967c37a25828e
Deleted: sha256:2302918bc81db19aa4d7ee71521db8ff4eb44d3ab4449c501f7539e88757ef2d
comcat@aisrv:/srv/mqtt/backup$ sudo docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
mysql               5.7.28              cd3ed0dfff7e        5 months ago        437MB


[编辑] 7 Export port

comcat@aisrv:/work/api.noduino/database$ docker run -tid --name emq20 -p 1883:1883 -p 8083:8083 -p 8883:8883 -p 8084:8084 -p 18083:18083 emqttd-docker-v2.1.2
docker: Error response from daemon: Conflict. The name "/emq20" is already in use by container 52df2e0d29b28509b2daae48a345cb1a44b2b5ed3ff268507cf223059d9b
You have to remove (or rename) that container to be able to reuse that name..

comcat@aisrv:/work/api.noduino/database$ docker start emq20
emq20



[编辑] 8 Passing options to the server

$ docker run --name test -e MYSQL_ROOT_PASSWORD=root -v $(pwd)/cos-db:/var/lib/mysql -d mysql/mysql-server:5.6 --explicit_defaults_for_timestamp=true



[编辑] 9 Mount host dir

  • place the dumped data file tempdb-xxx.sql in host dir cos-db/
  • not support the sym link
comcat@aisrv:/work/api.noduino/database$ docker run --name mysql -e MYSQL_ROOT_PASSWORD=root -v $(pwd)/cos-db:/var/lib/mysql -d mysql/mysql-server:5.6
987ab5054b83a14a2249650715353b4b9dddb0e78fcbc514ae37be975ca4c145
comcat@aisrv:/work/api.noduino/database$ docker ps
CONTAINER ID        IMAGE                    COMMAND                  CREATED             STATUS              PORTS               NAMES
987ab5054b83        mysql/mysql-server:5.6   "/entrypoint.sh mysql"   3 seconds ago       Up 2 seconds        3306/tcp            mysql

comcat@aisrv:/work/api.noduino/database$ ls cos-db
auto.cnf  ibdata1  ib_logfile0  ib_logfile1  mysql  mysql.sock  performance_schema  tempdb20170407.sql
comcat@aisrv:/work/api.noduino/database$ docker exec -it mysql bash
bash-4.2# ls /var/lib/mysql/
auto.cnf  ib_logfile0  ib_logfile1  ibdata1  mysql  mysql.sock  performance_schema  tempdb20170407.sql
bash-4.2# head /var/lib/mysql/tempdb20170407.sql
head: cannot open '/var/lib/mysql/tempdb20170407.sql' for reading: No such file or directory
bash-4.2# exit
exit
comcat@aisrv:/work/api.noduino/database$ rm cos-db/tempdb20170407.sql
comcat@aisrv:/work/api.noduino/database$ cp ../backup/tempdb20170407.sql cos-db/
comcat@aisrv:/work/api.noduino/database$ docker exec -it mysql bash
bash-4.2# head /var/lib/mysql/tempdb20170407.sql
-- MySQL dump 10.13  Distrib 5.5.49, for debian-linux-gnu (x86_64)
--
-- Host: localhost    Database: tempdb
-- ------------------------------------------------------
-- Server version   5.5.49-0ubuntu0.14.04.1

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;



[编辑] 10 dump all databases

$ docker exec mysql sh -c 'exec mysqldump --all-databases -uroot -p"$MYSQL_ROOT_PASSWORD"' > all.sql



[编辑] 11 dump table column

$ cat cos-db/getdevid.sql
select dvid from temp where productid='NNN1234' and uploadtime>'2017-03-01 00:00:00';

$ docker exec mysql sh -c 'exec mysql -uroot -p"$MYSQL_ROOT_PASSWORD" tempdb </var/lib/mysql/getdevid.sql > /var/lib/mysql/alldevid'



[编辑] 12 Restore Database

$ cp cos-tempdb-170507.sql test/
$ docker run --name test -e MYSQL_ROOT_PASSWORD=root -v $(pwd)/test:/var/lib/mysql -d mysql/mysql-server:5.6  --explicit_defaults_for_timestamp=true

$ docker exec test sh -c 'exec mysql -uroot -p"$MYSQL_ROOT_PASSWORD" < /var/lib/mysql/cos-tempdb-170507.sql';



[编辑] 13 Custom config file

$ docker exec -it cosdb cat /etc/my.cnf > my.cnf
$ docker --name cosdb -e MYSQL_ROOT_PASSWORD=root -v $(pwd)/my.cnf:/etc/my.cnf -v $(pwd)/test:/var/lib/mysql -d mysql/mysql-server:5.6  --explicit_defaults_for_timestamp=true



[编辑] 14 Using the data volume





[编辑] 15 Notes

$ docker run --name mydb -e MYSQL_ROOT_PASSWORD=root -v $(pwd)/mydb:/var/lib/mysql -d mysql/mysql-server:5.6  --explicit_defaults_for_timestamp=true
$ docker exec mydb sh -c 'exec mysql -uroot -p"$MYSQL_ROOT_PASSWORD" < /var/lib/mysql/cos-tempdb-170507.sql';
$ docker run --name nginx-php -v $(pwd)/wxmp:/var/www/html --link mydb:mysql -d richarvey/nginx-php-fpm

comcat@aisrv:/work/api.noduino/wxmp$ docker network ls
NETWORK ID          NAME                DRIVER              SCOPE
7fcde0337aa1        bridge              bridge              local
11451da05352        host                host                local
b91f895fe12c        none                null                local
comcat@aisrv:/work/api.noduino/wxmp$ docker network inspect --format='{{json .Containers}}' 7fcde0337aa1 | python -m json.tool
{
    "03535b5be172ce05c8ab5b43b8cdd80f9d04e3af8f47ba4911ea8fdc0161b87a": {
        "EndpointID": "d78fce5086d81cc0f9835018a50309a36b179bffb1a65848e2f2d74f5dc4e049",
        "IPv4Address": "172.17.0.2/16",
        "IPv6Address": "",
        "MacAddress": "02:42:ac:11:00:02",
        "Name": "mydb"
    },
    "2d7d38840458c6666980453c16c3798cdab4655e97b470b1f145494705de344a": {
        "EndpointID": "de8090170c4e6a73c401a8175375cc595a7c50a9afcbb50b04e11cdf1c0af239",
        "IPv4Address": "172.17.0.3/16",
        "IPv6Address": "",
        "MacAddress": "02:42:ac:11:00:03",
        "Name": "nginx-php"
    }
}

# export port
comcat@aisrv:/work/api.noduino/wxmp$ docker run -p 80:80 --name nginx-php -v $(pwd)/wxmp:/var/www/html --link mydb:mysql -d richarvey/nginx-php-fpm
054878b224c2ec32b67d80bbba50d605566bf1b6f19a9921c898dbd73d504647



[编辑] 16 nignx-php

Install PHP Modules

To install and configure extra PHP modules in this image, first of all drop into the container:

 docker exec -t -i nginx /bin/bash

Then configure and install your module:

 /usr/local/bin/docker-php-ext-configure sockets
 /usr/local/bin/docker-php-ext-install sockets

Now restart php-fpm:

supervisorctl restart php-fpm

We may include a env var to do this in the future.



[编辑] 17 Export Container

$ sudo docker export <CONTAINER ID> > /home/export.tar

[编辑] 18 Restore Container

$ cat /home/export.tar | sudo docker import - api-elec:latest


[编辑] 19 Export Image

例如我们想将镜像库中的postgres和mongo打包,那么可以执行:

$ sudo docker save -o images.tar postgres:9.6 mongo:3.4

恢复:

$ sudo docker load -i images.tar


[编辑] 20 Commit

comcat@aisrv:/work/docker$ docker ps
CONTAINER ID        IMAGE                   COMMAND                  CREATED             STATUS              PORTS                                     NAMES
e1bfd19e8626        srv-xda-api:0.9         "docker-php-entrypoin"   7 minutes ago       Up 7 minutes        443/tcp, 9000/tcp, 0.0.0.0:8000->80/tcp   xda-srv
comcat@aisrv:/work/docker$ docker stop e1
e1
comcat@aisrv:/work/docker$ docker commit e1b srv-xda-api:0.9.2
sha256:f39c64c92367be2569d98ce889d4863dbb85f30bc425ecd0fdeea21bb43eb486
comcat@aisrv:/work/docker$ docker images
REPOSITORY                TAG                 IMAGE ID            CREATED             SIZE
srv-xda-api               0.9.2               f39c64c92367        5 seconds ago       345.2 MB
srv-xda-api               0.9                 a160e6e42d1c        9 minutes ago       345.2 MB

comcat@aisrv:/work/docker$ docker run -d -e DB_HOST="192.168.1.20" -p 8000:80 srv-xda-api:0.9.2
4e6bfec25da6d33d3b9a3aa03b62f07ce2f8e61528e7292b140da99d80cef767
comcat@aisrv:/work/docker$ docker ps
CONTAINER ID        IMAGE                   COMMAND                  CREATED             STATUS              PORTS                                     NAMES
4e6bfec25da6        srv-xda-api:0.9.2       "docker-php-entrypoin"   3 seconds ago       Up 2 seconds        443/tcp, 9000/tcp, 0.0.0.0:8000->80/tcp   fervent_stonebraker

[编辑] 21 Reference


[编辑] 21.1 批处理


[编辑] 21.2 PowerShell







[编辑] 21.3 MySQL

https://hub.docker.com/_/mysql

  • 8.0.18, 8.0, 8, latest
  • 5.7.28, 5.7, 5
  • 5.6.46, 5.6

https://github.com/docker-library/mysql/issues

Env variables:

  • MYSQL_ROOT_PASSWORD
  • MYSQL_DATABASE
  • MYSQL_USER, MYSQL_PASSWORD
  • MYSQL_ALLOW_EMPTY_PASSWORD
  • MYSQL_RANDOM_ROOT_PASSWORD
  • MYSQL_ONETIME_PASSWORD
$ docker run --name some-mysql -v /my/own/datadir:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:5.6

$ docker logs some-mysql                  # check logs

$ docker run --name some-mysql -v /my/custom:/etc/mysql/conf.d -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:5.6.46
$ docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:5.6 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci

$ docker run -it --rm mysql:5.6 --verbose --help

$ docker run -v /srv/data:/var/lib/mysql --user 1000:1000 --name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:5.6
$ docker exec some-mysql sh -c 'exec mysqldump --all-databases -uroot -p"$MYSQL_ROOT_PASSWORD"' > /some/path/on/your/host/all-databases.sql
$ docker exec -i some-mysql sh -c 'exec mysql -uroot -p"$MYSQL_ROOT_PASSWORD"' < /some/path/on/your/host/all-databases.sql

docker stack deploy or docker-compose, example stack.yml for mysql:

# Use root/example as user/password credentials
version: '3.1'

services:

  db:
    image: mysql
    command: --default-authentication-plugin=mysql_native_password
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: example

  adminer:
    image: adminer
    restart: always
    ports:
      - 8080:8080



[编辑] 21.4 IIS

Create a Dockerfile with your website

FROM mcr.microsoft.com/windows/servercore/iis

RUN powershell -NoProfile -Command Remove-Item -Recurse C:\inetpub\wwwroot\*

WORKDIR /inetpub/wwwroot

COPY content/ .

You can then build and run the Docker image:

 $ docker build -t iis-site .
 $ docker run -d -p 8000:80 --name my-running-site iis-site

There is no need to specify an ENTRYPOINT in your Dockerfile since the microsoft/iis base image already includes an entrypoint application that monitors the status of the IIS World Wide Web Publishing Service (W3SVC).

Verify in the browser

With the current release, you can't use http://localhost to browse your site from the container host. This is because of a known behavior in WinNAT, and will be resolved in future. Until that is addressed, you need to use the IP address of the container.

Once the container starts, you'll need to finds its IP address so that you can connect to your running container from a browser. You use the docker inspect command to do that:

docker inspect -f "{{ .NetworkSettings.Networks.nat.IPAddress }}" my-running-site

You will see an output similar to this:

 172.28.103.186

You can connect the running container using the IP address and configured port, http://172.28.103.186:8000 in the example shown.

In addition to static content, IIS can run other workloads including but not limited to ASP.NET, ASP.NET Core, NodeJS, PHP, and Apache Tomcat.

For a comprehensive tutorial on running an ASP.NET app in a container, check out the tutorial on the docs site.

将 ASP.NET MVC 应用程序迁移到 Windows 容器



[编辑] 21.5 ASP.NET

Featured Tags
4.8
docker pull mcr.microsoft.com/dotnet/framework/aspnet:4.8
3.5
docker pull mcr.microsoft.com/dotnet/framework/aspnet:3.5
About This Image
ASP.NET is a high productivity framework for building Web Applications using Web Forms, MVC, Web API and SignalR.

This image contains:

Windows Server Core as the base OS
IIS 10 as Web Server
.NET Framework (multiple versions available)
.NET Extensibility for IIS
Watch dotnet/announcements for Docker-related .NET announcements.

How to use these Images
The .NET Framework Docker samples show various ways to use .NET Framework and Docker together.

Container sample: Run an ASP.NET application
You can quickly run a container with a pre-built sample ASP.NET Docker image, based on the [ASP.NET Docker sample].

Type the following Docker command:

docker run --name aspnet_sample --rm -it -p 8000:80 mcr.microsoft.com/dotnet/framework/samples:aspnetapp
After the application starts, navigate to http://localhost:8000 in your web browser. You need to navigate to the application via IP address
instead of localhost for earlier Windows versions, which is demonstrated in View the ASP.NET app in a running container on Windows.

Related Repos
.NET Framework:

dotnet/framework/sdk: .NET Framework SDK
dotnet/framework/runtime: .NET Framework Runtime
dotnet/framework/wcf: Windows Communication Framework (WCF)
dotnet/framework/samples: .NET Framework, ASP.NET and WCF Samples
.NET Core:

dotnet/core: .NET Core
dotnet/core-nightly: .NET Core (Preview)
dotnet/core/samples: .NET Core Samples







个人工具
名字空间

变换
操作
导航
工具箱