The last article mentioned that Oracle Cloud’s free and popular 4c24g VM.Standard.A1.Flex model is difficult to apply, but in actual use, there are still many traps in the Oracle Cloud free package. The following are some common situations:
Free hosting is over quota, free storage is over quota, oc priority to stop the resource is this A1.Flex vps 。
Flex.A1 The optional operating system is only oracle linux v7 or v8 , if you like ubuntu…😭
When the operating system is broken, unlike general cloud service consoles that can restore the image, you can only reapply
Using a container as a virtual machine is not in line with the original intention of container application deployment, but in view of the above problems, docker is used to create a container instead of a virtual machine in this article. Everything is operated in the virtual machine. When the system disaster is unrecoverable, just delete container and Create the container again.
Deployment steps
ssh Log in to the host
1、Install docker
yum install docker
2、Dockerfile
Writing Dockerfile
FROM ubuntu:20.04
LABEL MAINTAINER="luckfu.com"
USER root
# change root password to `ubuntu`
RUN echo 'root:ubuntu' | chpasswd
ENV DEBIAN_FRONTEND noninteractive
# install ssh server
RUN apt-get update && apt-get install -y \
openssh-server sudo \
&& rm -rf /var/lib/apt/lists/* \
&& mkdir -p /run/sshd \
&& ssh-keygen -A \
&& sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/g' /etc/ssh/sshd_config \
&& apt-get purge -y --auto-remove
EXPOSE 22
# run ssh server
CMD ["/usr/sbin/sshd", "-D", "-o", "ListenAddress=0.0.0.0"]
3、Generate image
docker build -f ./Dockerfile -t ubuntu-ssh
docker images view image list
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntuos-ssh latest b6010c26ebb7 1 days ago 189MB
ubuntu 20.04 d5ca7a445605 8 weeks ago 65.6MB
4、Launching containers
执行命令
docker run -d -p 9022:22 -p 8000-9000:8000-9000 \
-v /data/:/data \
--name ubuntuos-ssh ubuntuos-ssh
parameters and meaning:
Parameters | Description |
---|---|
-d | Daemon mode |
-p | Port Mapping [host port:Port in container] |
-v | volume mapping [host vol:container vol] |
–name | container name ubuntu-ssh |
In the above command, we deployed a container named ubuntuos-ssh, and set the host’s /data (you can apply for 100G “always free” storage in the oracle cloud and mount it to the host /data) is mounted under the /data of the container, and 9022 of the host is mapped to port 22 of the ssh service of the container, and ports 8000-9000 are opened for spare
Check if the container is running
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0c9cf191daf2 ubuntuos-ssh "/usr/sbin/sshd -D -…" 12 days ago Up 12 days 0.0.0.0:8000-9000->8000-9000/tcp, :::8000-9000->8000-9000/tcp, 0.0.0.0:9022->22/tcp, :::9022->22/tcp ubuntuos-ssh
Log in to the container
use ssh instead of exec -it to enter
password: ubuntu
ssh root@localhost -p 9022
root@localhost's password:
(base) root@xxxxxxx:~#
If login success, the container is running normally
5、Login from internet
Login to Oracle Cloud
- Check VNC config ,port 22 8000-9000 used by the container is open
- checks the firewall such as iptables firwwall,port is open
ssh root@IP -p 9022
Let’s play