Docker開發篇 | 01-Docker安裝最新版本ubuntu並啟動容器
一、拉取最新ubuntu映象
$ docker pull ubuntu:latest
latest: Pulling from library/ubuntu
d72e567cc804: Pull complete
0f3630e5ff08: Pull complete
b6a83d81d1f4: Pull complete
Digest: sha256:bc2f7250f69267c9c6b66d7b6a81a54d3878bb85f1ebb5f951c896d13e6ba537
Status: Downloaded newer image for ubuntu:latest
docker.io/library/ubuntu:latest
二、生成ubuntu容器並退出
$ docker container run -p 8000:3000 -it ubuntu:latest /bin/bash
root@bc7c3ac008b2:/# exit
三、檢視ubuntu容器資訊
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
bc7c3ac008b2 ubuntu:latest "/bin/bash" 28 seconds ago Exited (0) 13 seconds ago 0.0.0.0:8000->3000/tcp zealous_einstein
四、更改ubuntu容器為特定名字
$ docker rename bc7c3ac008b2 ubuntu-latest-buildroot
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
bc7c3ac008b2 ubuntu:latest "/bin/bash" 2 minutes ago Exited (0) 2 minutes ago 0.0.0.0:8000->3000/tcp ubuntu-latest-buildroot
注意:名字可以隨便命名,此處博主是用於編譯buildroot使用的。
五、啟動並進入ubuntu容器
$ docker container start ubuntu-latest-buildroot
ubuntu-latest-buildroot
$ docker container exec -it ubuntu-latest-buildroot /bin/bash
六、檢視ubuntu容器版本
root@bc7c3ac008b2:/# cat /etc/issue
Ubuntu 20.04.1 LTS \n \l
七、更新apt源
root@bc7c3ac008b2:/# apt update
Get:1 http://security.ubuntu.com/ubuntu focal-security InRelease [107 kB]
Get:2 http://archive.ubuntu.com/ubuntu focal InRelease [265 kB]
Get:3 http://archive.ubuntu.com/ubuntu focal-updates InRelease [111 kB]
Get:4 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages [367 kB]
Get:5 http://archive.ubuntu.com/ubuntu focal-backports InRelease [98.3 kB]
Get:6 http://security.ubuntu.com/ubuntu focal-security/restricted amd64 Packages [75.9 kB]
Get:7 http://security.ubuntu.com/ubuntu focal-security/universe amd64 Packages [112 kB]
Get:8 http://security.ubuntu.com/ubuntu focal-security/multiverse amd64 Packages [1169 B]
Get:9 http://archive.ubuntu.com/ubuntu focal/main amd64 Packages [1275 kB]
Get:10 http://archive.ubuntu.com/ubuntu focal/universe amd64 Packages [11.3 MB]
Get:11 http://archive.ubuntu.com/ubuntu focal/restricted amd64 Packages [33.4 kB]
Get:12 http://archive.ubuntu.com/ubuntu focal/multiverse amd64 Packages [177 kB]
Get:13 http://archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages [303 kB]
Get:14 http://archive.ubuntu.com/ubuntu focal-updates/multiverse amd64 Packages [21.6 kB]
Get:15 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [703 kB]
Get:16 http://archive.ubuntu.com/ubuntu focal-updates/restricted amd64 Packages [88.7 kB]
Get:17 http://archive.ubuntu.com/ubuntu focal-backports/universe amd64 Packages [4277 B]
Fetched 15.1 MB in 29s (527 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.
八、安裝常用命令
$ apt install byobu vim-gtk inetutils-ping net-tools wget cpio unzip rsync
九、安裝sudo命令並新增普通使用者
$ apt install sudo
$ adduser neutionwei
十、把普通使用者新增到sudo
$ visido
新增如下內容:
neutionwei ALL=(ALL:ALL) ALL
十一、切換到普通使用者
$ su neutionwei
相關文章
- Ubuntu 安裝最新 docker docker-composeUbuntuDocker
- ubuntu 安裝指定版本dockerUbuntuDocker
- 測試開發之系統篇-Docker容器安裝Docker
- Ubuntu 18.04 安裝最新版 DockerUbuntuDocker
- Ubuntu 18.04.6 TLS版本安裝docker問題UbuntuTLSDocker
- Ubuntu下 解除安裝protobuf並安裝指定版本的protobufUbuntu
- Ubuntu 安裝最新版本 Node.jsUbuntuNode.js
- docker安裝redis並以配置檔案方式啟動DockerRedis
- ubuntu 安裝 dockerUbuntuDocker
- ubuntu安裝dockerUbuntuDocker
- Ubuntu Docker 安裝UbuntuDocker
- 在Ubuntu上安裝最新版本的HandbrakeUbuntu
- Ubuntu 安裝 Docker DesktopUbuntuDocker
- 【ubuntu】22.04安裝dockerUbuntuDocker
- ubuntu 18.04 安裝dockerUbuntuDocker
- Ubuntu 安裝 docker[laradock]UbuntuDocker
- Ubuntu中安裝DockerUbuntuDocker
- docker容器安裝MySQLDockerMySql
- docker容器安裝vimDocker
- Ubuntu最新版本(Ubuntu22.04LTS)安裝nfs伺服器UbuntuNFS伺服器
- 如何在 Ubuntu 上安裝最新版本的 GitUbuntuGit
- ubuntu 16.04下安裝最新版本nodejs和npmUbuntuNodeJSNPM
- Ubuntu安裝golang多版本UbuntuGolang
- Ubuntu安裝Docker及Docker-composeUbuntuDocker
- Ubuntu24.04安裝DockerUbuntuDocker
- Ubuntu安裝nvidia-dockerUbuntuDocker
- Ubuntu安裝docker筆記UbuntuDocker筆記
- ubuntu18.04 安裝dockerUbuntuDocker
- 快速部署-01-dockerDocker
- docker 容器安裝配置 headscaleDocker
- (四)Docker安裝使用容器Docker
- 完全使用 Docker 開發 PHP 專案 (一): 安裝篇DockerPHP
- Ubuntu安裝最新版nodejsUbuntuNodeJS
- 解決docker安裝minio容器時,minio容器啟動幾秒後自動退出的一種方法Docker
- docker 安裝最新的 jenkinsDockerJenkins
- Docker重啟保持容器自動啟動Docker
- Yapi——2安裝並開啟YapiAPI
- Docker容器的自啟動Docker