Code Monkey home page Code Monkey logo

docker-ubuntu2204's Introduction

docker-ubuntu2204

Ubuntu 22.04 LTS Docker 镜像

构建镜像

git clone https://github.com/fifilyu/docker-ubuntu2204.git
cd docker-ubuntu2204
sh build.sh

使用方法

启动一个容器很简单

docker run -d \
    --env LANG=en_US.UTF-8 \
    --env TZ=Asia/Shanghai \
    --name ubuntu2204 \
    fifilyu/ubuntu2204:latest

显示容器 IP:

docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ubuntu2204

查看 root 用户随机密码:

docker logs ubuntu2204

SSH 远程连接:

ssh root@容器IP -v

启动带公钥的容器

docker run -d \
--env LANG=en_US.UTF-8 \
    --env TZ=Asia/Shanghai \
    --env PUBLIC_STR="$(<~/.ssh/[email protected])" \
    --name ubuntu2204_key \
    fifilyu/ubuntu2204:latest

效果同上。另外,可以通过 SSH 无密码登录容器。

$(<~/.ssh/[email protected]) 表示在命令行读取文件内容到变量。

PUBLIC_STR="$(<~/.ssh/[email protected])" 也可以写作:

PUBLIC_STR="ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDLGJVJI1Cqr59VH1NVQgPs08n7e/HRc2Q8AUpOWGoJpVzIgjO+ipjqwnxh3eiBd806eXIIa5OFwRm0fYfMFxBOdo3l5qGtBe82PwTotdtpcacP5Dkrn+HZ1kG+cf0BNSF5oXbTCTrqY12/T8h4035BXyRw7+MuVPiCUhydYs3RgsODA47ZR3owgjvPsayUd5MrD8gidGqv1zdyW9nQXnXB7m9Sn9Mg8rk6qBxQUbtMN9ez0BFrUGhXCkW562zhJjP5j4RLVfvL2N1bWT9EoFTCjk55pv58j+PTNEGUmu8PrU8mtgf6zQO871whTD8/H6brzaMwuB5Rd5OYkVir0BXj fifilyu@archlinux"

启动容器时映射端口

docker run -d \
--env LANG=en_US.UTF-8 \
    --env TZ=Asia/Shanghai \
    -p 1022:22 \
    --name ubuntu2204_port \
    fifilyu/ubuntu2204:latest

执行 ssh [email protected] -p 1022 -v 测试 SSH 端口状态

自定义设置

自定义配置参数,可以直接通过 Docker 命令进入 bash 编辑:

docker exec -it 容器名称 bash

或者通过 SSH+私钥方式连接容器的 22 端口:

ssh root@容器IP

镜像变更内容

开放端口

  • SSHD->22(通过 SSH+私钥方式连接容器的 22 端口,方便查看日志)

启动服务

  • OpenSSH Daemon(sshd)

文件列表

  • /etc/ssh/sshd_config
  • /etc/security/limits.conf
  • /etc/profile.d/python3.sh
  • /usr/local/bin/jq
  • /usr/local/python3
  • /usr/local/python-3.12.2
  • /root/.ssh/authorized_keys

软件包

Python

  • python312

命令行编辑工具

  • xmlstarlet(xml)
  • crudini(ini)
  • jq(json)
  • yq(yaml)
  • toml-cli(toml)

常用工具

  • apt-file
  • aptitude
  • bzip2
  • curl
  • iproute2
  • mlocate
  • openssh-client
  • openssh-server
  • openssl
  • pwgen
  • rsync
  • screen
  • sudo
  • tar
  • tcpdump
  • telnet
  • vim
  • wget
  • xz-utils

docker-ubuntu2204's People

Contributors

fifilyu avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.